Contract 0xfa07af9e5835d720b3798a37f716749252f94d71 11

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x8c16fd19ae7fafc94c4a882823cc82de9283f1d9fdda52250b9b77e7f15bc47a0x60806040235489522022-08-06 1:29:40601 days 8 hrs ago0x54812dbab593674cd4f1216264895be48b55c5e3 IN  Create: CaskSubscriptions0 xDAI0.015947169
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Index Block
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CaskSubscriptions

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 20 : CaskSubscriptions.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "@opengsn/contracts/src/BaseRelayRecipient.sol";


import "../interfaces/ICaskSubscriptionManager.sol";
import "../interfaces/ICaskSubscriptions.sol";
import "../interfaces/ICaskSubscriptionPlans.sol";

contract CaskSubscriptions is
ICaskSubscriptions,
BaseRelayRecipient,
ERC721Upgradeable,
OwnableUpgradeable,
PausableUpgradeable
{
    using ECDSA for bytes32;

    /************************** PARAMETERS **************************/

    /** @dev contract to manage subscription plan definitions. */
    ICaskSubscriptionManager public subscriptionManager;

    /** @dev contract to manage subscription plan definitions. */
    ICaskSubscriptionPlans public subscriptionPlans;


    /************************** STATE **************************/

    /** @dev Maps for consumer to list of subscriptions. */
    mapping(address => uint256[]) private consumerSubscriptions; // consumer => subscriptionId[]
    mapping(uint256 => Subscription) private subscriptions; // subscriptionId => Subscription
    mapping(uint256 => bytes32) private pendingPlanChanges; // subscriptionId => planData

    /** @dev Maps for provider to list of subscriptions and plans. */
    mapping(address => uint256[]) private providerSubscriptions; // provider => subscriptionId[]
    mapping(address => uint256) private providerActiveSubscriptionCount; // provider => count
    mapping(address => mapping(uint32 => uint256)) private planActiveSubscriptionCount; // provider => planId => count
    mapping(address => mapping(address => mapping(uint32 => uint256))) private consumerProviderPlanActiveCount;

    modifier onlyManager() {
        require(_msgSender() == address(subscriptionManager), "!AUTH");
        _;
    }

    modifier onlySubscriber(uint256 _subscriptionId) {
        require(_msgSender() == ownerOf(_subscriptionId), "!AUTH");
        _;
    }

    modifier onlySubscriberOrProvider(uint256 _subscriptionId) {
        require(
            _msgSender() == ownerOf(_subscriptionId) ||
            _msgSender() == subscriptions[_subscriptionId].provider,
            "!AUTH"
        );
        _;
    }

    function initialize(
        address _subscriptionPlans
    ) public initializer {
        __Ownable_init();
        __Pausable_init();
        __ERC721_init("Cask Subscriptions","CASKSUBS");

        subscriptionPlans = ICaskSubscriptionPlans(_subscriptionPlans);
    }
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() initializer {}

    function versionRecipient() public pure override returns(string memory) { return "2.2.0"; }

    function _msgSender() internal view override(ContextUpgradeable, BaseRelayRecipient)
    returns (address sender) {
        sender = BaseRelayRecipient._msgSender();
    }

    function _msgData() internal view override(ContextUpgradeable, BaseRelayRecipient)
    returns (bytes calldata) {
        return BaseRelayRecipient._msgData();
    }


    function tokenURI(uint256 _subscriptionId) public view override returns (string memory) {
        require(_exists(_subscriptionId), "ERC721Metadata: URI query for nonexistent token");

        Subscription memory subscription = subscriptions[_subscriptionId];

        return string(abi.encodePacked("ipfs://", subscription.cid));
    }

    function _beforeTokenTransfer(
        address _from,
        address _to,
        uint256 _subscriptionId
    ) internal override {
        if (_from != address(0) && _to != address(0)) { // only non-mint/burn transfers
            Subscription storage subscription = subscriptions[_subscriptionId];

            PlanInfo memory planInfo = _parsePlanData(subscription.planData);
            require(planInfo.canTransfer, "!NOT_TRANSFERRABLE");

            require(subscription.minTermAt == 0 || uint32(block.timestamp) >= subscription.minTermAt, "!MIN_TERM");

            // on transfer, set subscription to cancel at next renewal until new owner accepts subscription
            subscription.cancelAt = subscription.renewAt;
            consumerSubscriptions[_to].push(_subscriptionId);
        }
    }

    /************************** SUBSCRIPTION METHODS **************************/

    function createNetworkSubscription(
        uint256 _nonce,
        bytes32[] calldata _planProof,  // [provider, ref, planData, merkleRoot, merkleProof...]
        bytes32[] calldata _discountProof, // [discountCodeProof, discountData, merkleRoot, merkleProof...]
        bytes32 _networkData,
        uint32 _cancelAt,
        bytes memory _providerSignature,
        bytes memory _networkSignature,
        string calldata _cid
    ) external override whenNotPaused {
        uint256 subscriptionId = _createSubscription(_nonce, _planProof, _discountProof, _cancelAt,
            _providerSignature, _cid);

        _verifyNetworkData(_networkData, _networkSignature);

        Subscription storage subscription = subscriptions[subscriptionId];
        subscription.networkData = _networkData;
    }

    function createSubscription(
        uint256 _nonce,
        bytes32[] calldata _planProof, // [provider, ref, planData, merkleRoot, merkleProof...]
        bytes32[] calldata _discountProof, // [discountCodeProof, discountData, merkleRoot, merkleProof...]
        uint32 _cancelAt,
        bytes memory _providerSignature,
        string calldata _cid
    ) external override whenNotPaused {
        _createSubscription(_nonce, _planProof, _discountProof, _cancelAt, _providerSignature, _cid);
    }

    function attachData(
        uint256 _subscriptionId,
        string calldata _dataCid
    ) external override onlySubscriberOrProvider(_subscriptionId) whenNotPaused {
        Subscription storage subscription = subscriptions[_subscriptionId];
        require(subscription.status != SubscriptionStatus.Canceled, "!CANCELED");
        subscription.dataCid = _dataCid;
    }

    function changeSubscriptionPlan(
        uint256 _subscriptionId,
        uint256 _nonce,
        bytes32[] calldata _planProof,  // [provider, ref, planData, merkleRoot, merkleProof...]
        bytes32[] calldata _discountProof, // [discountCodeProof, discountData, merkleRoot, merkleProof...]
        bytes memory _providerSignature,
        string calldata _cid
    ) external override onlySubscriber(_subscriptionId) whenNotPaused {
        _changeSubscriptionPlan(_subscriptionId, _nonce, _planProof, _discountProof, _providerSignature, _cid);
    }

    function pauseSubscription(
        uint256 _subscriptionId
    ) external override onlySubscriberOrProvider(_subscriptionId) whenNotPaused {

        Subscription storage subscription = subscriptions[_subscriptionId];

        require(subscription.status != SubscriptionStatus.Paused &&
                subscription.status != SubscriptionStatus.PastDue &&
                subscription.status != SubscriptionStatus.Canceled &&
                subscription.status != SubscriptionStatus.Trialing, "!INVALID(status)");

        require(subscription.minTermAt == 0 || uint32(block.timestamp) >= subscription.minTermAt, "!MIN_TERM");

        PlanInfo memory planInfo = _parsePlanData(subscription.planData);
        require(planInfo.canPause, "!NOT_PAUSABLE");

        subscription.status = SubscriptionStatus.PendingPause;

        emit SubscriptionPendingPause(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
            subscription.ref, subscription.planId);
    }

    function resumeSubscription(
        uint256 _subscriptionId
    ) external override onlySubscriber(_subscriptionId) whenNotPaused {

        Subscription storage subscription = subscriptions[_subscriptionId];

        require(subscription.status == SubscriptionStatus.Paused ||
                subscription.status == SubscriptionStatus.PendingPause, "!NOT_PAUSED");

        emit SubscriptionResumed(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
            subscription.ref, subscription.planId);

        if (subscription.status == SubscriptionStatus.PendingPause) {
            subscription.status = SubscriptionStatus.Active;
            return;
        }

        PlanInfo memory planInfo = _parsePlanData(subscription.planData);

        require(planInfo.maxActive == 0 ||
            planActiveSubscriptionCount[subscription.provider][planInfo.planId] < planInfo.maxActive, "!MAX_ACTIVE");

        subscription.status = SubscriptionStatus.Active;

        providerActiveSubscriptionCount[subscription.provider] += 1;
        planActiveSubscriptionCount[subscription.provider][subscription.planId] += 1;
        consumerProviderPlanActiveCount[ownerOf(_subscriptionId)][subscription.provider][subscription.planId] += 1;

        // if renewal date has already passed, set it to now so consumer is not charged for the time it was paused
        if (subscription.renewAt < uint32(block.timestamp)) {
            subscription.renewAt = uint32(block.timestamp);
        }

        // re-register subscription with manager
        subscriptionManager.renewSubscription(_subscriptionId);

        // make sure still active if payment was required to resume
        require(subscription.status == SubscriptionStatus.Active, "!INSUFFICIENT_FUNDS");
    }

    function cancelSubscription(
        uint256 _subscriptionId,
        uint32 _cancelAt
    ) external override onlySubscriberOrProvider(_subscriptionId) whenNotPaused {

        Subscription storage subscription = subscriptions[_subscriptionId];

        require(subscription.status != SubscriptionStatus.Canceled, "!INVALID(status)");

        uint32 timestamp = uint32(block.timestamp);

        if(_cancelAt == 0) {
            require(_msgSender() == ownerOf(_subscriptionId), "!AUTH"); // clearing cancel only allowed by subscriber
            subscription.cancelAt = _cancelAt;

            emit SubscriptionPendingCancel(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
                subscription.ref, subscription.planId, _cancelAt);
        } else if(_cancelAt <= timestamp) {
            require(subscription.minTermAt == 0 || timestamp >= subscription.minTermAt, "!MIN_TERM");
            subscription.renewAt = timestamp;
            subscription.cancelAt = timestamp;
            subscriptionManager.renewSubscription(_subscriptionId); // force manager to process cancel
        } else {
            require(subscription.minTermAt == 0 || _cancelAt >= subscription.minTermAt, "!MIN_TERM");
            subscription.cancelAt = _cancelAt;

            emit SubscriptionPendingCancel(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
                subscription.ref, subscription.planId, _cancelAt);
        }
    }

    function managerCommand(
        uint256 _subscriptionId,
        ManagerCommand _command
    ) external override onlyManager whenNotPaused {

        Subscription storage subscription = subscriptions[_subscriptionId];

        uint32 timestamp = uint32(block.timestamp);

        if (_command == ManagerCommand.PlanChange) {
            bytes32 pendingPlanData = pendingPlanChanges[_subscriptionId];
            require(pendingPlanData > 0, "!INVALID(pendingPlanData)");

            PlanInfo memory newPlanInfo = _parsePlanData(pendingPlanData);

            emit SubscriptionChangedPlan(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
                subscription.ref, subscription.planId, newPlanInfo.planId, subscription.discountId);

            subscription.planId = newPlanInfo.planId;
            subscription.planData = pendingPlanData;

            if (newPlanInfo.minPeriods > 0) {
                subscription.minTermAt = timestamp + (newPlanInfo.period * newPlanInfo.minPeriods);
            }

            delete pendingPlanChanges[_subscriptionId]; // free up memory

        } else if (_command == ManagerCommand.Cancel) {
            subscription.status = SubscriptionStatus.Canceled;

            providerActiveSubscriptionCount[subscription.provider] -= 1;
            planActiveSubscriptionCount[subscription.provider][subscription.planId] -= 1;
            if (consumerProviderPlanActiveCount[ownerOf(_subscriptionId)][subscription.provider][subscription.planId] > 0) {
                consumerProviderPlanActiveCount[ownerOf(_subscriptionId)][subscription.provider][subscription.planId] -= 1;
            }

            emit SubscriptionCanceled(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
                subscription.ref, subscription.planId);

            _burn(_subscriptionId);

        } else if (_command == ManagerCommand.Pause) {
            subscription.status = SubscriptionStatus.Paused;

            providerActiveSubscriptionCount[subscription.provider] -= 1;
            planActiveSubscriptionCount[subscription.provider][subscription.planId] -= 1;
            if (consumerProviderPlanActiveCount[ownerOf(_subscriptionId)][subscription.provider][subscription.planId] > 0) {
                consumerProviderPlanActiveCount[ownerOf(_subscriptionId)][subscription.provider][subscription.planId] -= 1;
            }

            emit SubscriptionPaused(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
                subscription.ref, subscription.planId);

        } else if (_command == ManagerCommand.PastDue) {
            subscription.status = SubscriptionStatus.PastDue;

            emit SubscriptionPastDue(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
                subscription.ref, subscription.planId);

        } else if (_command == ManagerCommand.Renew) {
            PlanInfo memory planInfo = _parsePlanData(subscription.planData);

            if (subscription.status == SubscriptionStatus.Trialing) {
                emit SubscriptionTrialEnded(ownerOf(_subscriptionId), subscription.provider,
                    _subscriptionId, subscription.ref, subscription.planId);
            }

            subscription.renewAt = subscription.renewAt + planInfo.period;

            if (subscription.renewAt > timestamp) {
                // leave in current status unless subscription is current
                subscription.status = SubscriptionStatus.Active;
            }

            emit SubscriptionRenewed(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
                subscription.ref, subscription.planId);

        } else if (_command == ManagerCommand.ClearDiscount) {
                    subscription.discountId = 0;
                    subscription.discountData = 0;
        }

    }

    function getSubscription(
        uint256 _subscriptionId
    ) external override view returns (Subscription memory subscription, address currentOwner) {
        subscription = subscriptions[_subscriptionId];
        if (_exists(_subscriptionId)) {
            currentOwner = ownerOf(_subscriptionId);
        } else {
            currentOwner = address(0);
        }
    }

    function getConsumerSubscription(
        address _consumer,
        uint256 _idx
    ) external override view returns(uint256) {
        return consumerSubscriptions[_consumer][_idx];
    }

    function getActiveSubscriptionCount(
        address _consumer,
        address _provider,
        uint32 _planId
    ) external override view returns(uint256) {
        return consumerProviderPlanActiveCount[_consumer][_provider][_planId];
    }

    function getConsumerSubscriptionCount(
        address _consumer
    ) external override view returns (uint256) {
        return consumerSubscriptions[_consumer].length;
    }

    function getProviderSubscription(
        address _provider,
        uint256 _idx
    ) external override view returns(uint256) {
        return providerSubscriptions[_provider][_idx];
    }

    function getProviderSubscriptionCount(
        address _provider,
        bool _includeCanceled,
        uint32 _planId
    ) external override view returns (uint256) {
        if (_includeCanceled) {
            return providerSubscriptions[_provider].length;
        } else {
            if (_planId > 0) {
                return planActiveSubscriptionCount[_provider][_planId];
            } else {
                return providerActiveSubscriptionCount[_provider];
            }
        }
    }

    function getPendingPlanChange(
        uint256 _subscriptionId
    ) external override view returns (bytes32) {
        return pendingPlanChanges[_subscriptionId];
    }

    function _createSubscription(
        uint256 _nonce,
        bytes32[] calldata _planProof,  // [provider, ref, planData, merkleRoot, merkleProof...]
        bytes32[] calldata _discountProof, // [discountCodeProof, discountData, merkleRoot, merkleProof...]
        uint32 _cancelAt,
        bytes memory _providerSignature,
        string calldata _cid
    ) internal returns(uint256) {
        require(_planProof.length >= 4, "!INVALID(planProofLen)");

        // confirms merkleroots are in fact the ones provider committed to
        address provider;
        if (_discountProof.length >= 3) {
            provider = _verifyMerkleRoots(_planProof[0], _nonce, _planProof[3], _discountProof[2], _providerSignature);
        } else {
            provider = _verifyMerkleRoots(_planProof[0], _nonce, _planProof[3], 0, _providerSignature);
        }

        // confirms plan data is included in merkle root
        require(_verifyPlanProof(_planProof), "!INVALID(planProof)");

        // decode planData bytes32 into PlanInfo
        PlanInfo memory planInfo = _parsePlanData(_planProof[2]);

        // generate subscriptionId from plan info and ref
        uint256 subscriptionId = _generateSubscriptionId(_planProof[0], _planProof[1], _planProof[2]);

        require(planInfo.maxActive == 0 ||
            planActiveSubscriptionCount[provider][planInfo.planId] < planInfo.maxActive, "!MAX_ACTIVE");
        require(subscriptionPlans.getPlanStatus(provider, planInfo.planId) ==
            ICaskSubscriptionPlans.PlanStatus.Enabled, "!NOT_ENABLED");

        _safeMint(_msgSender(), subscriptionId);

        Subscription storage subscription = subscriptions[subscriptionId];

        uint32 timestamp = uint32(block.timestamp);

        subscription.provider = provider;
        subscription.planId = planInfo.planId;
        subscription.ref = _planProof[1];
        subscription.planData = _planProof[2];
        subscription.cancelAt = _cancelAt;
        subscription.cid = _cid;
        subscription.createdAt = timestamp;

        if (planInfo.minPeriods > 0) {
            subscription.minTermAt = timestamp + (planInfo.period * planInfo.minPeriods);
        }

        if (planInfo.price == 0) {
            // free plan, never renew to save gas
            subscription.status = SubscriptionStatus.Active;
            subscription.renewAt = 0;
        } else if (planInfo.freeTrial > 0) {
            // if trial period, charge will happen after trial is over
            subscription.status = SubscriptionStatus.Trialing;
            subscription.renewAt = timestamp + planInfo.freeTrial;
        } else {
            // if no trial period, charge now
            subscription.status = SubscriptionStatus.Active;
            subscription.renewAt = timestamp;
        }

        consumerSubscriptions[_msgSender()].push(subscriptionId);
        providerSubscriptions[provider].push(subscriptionId);
        providerActiveSubscriptionCount[provider] += 1;
        planActiveSubscriptionCount[provider][planInfo.planId] += 1;
        consumerProviderPlanActiveCount[_msgSender()][provider][planInfo.planId] += 1;

        (
        subscription.discountId,
        subscription.discountData
        ) = _verifyDiscountProof(ownerOf(subscriptionId), subscription.provider, planInfo.planId, _discountProof);

        subscriptionManager.renewSubscription(subscriptionId); // registers subscription with manager

        require(subscription.status == SubscriptionStatus.Active ||
                subscription.status == SubscriptionStatus.Trialing, "!UNPROCESSABLE");

        emit SubscriptionCreated(ownerOf(subscriptionId), subscription.provider, subscriptionId,
            subscription.ref, subscription.planId, subscription.discountId);

        return subscriptionId;
    }

    function _changeSubscriptionPlan(
        uint256 _subscriptionId,
        uint256 _nonce,
        bytes32[] calldata _planProof,  // [provider, ref, planData, merkleRoot, merkleProof...]
        bytes32[] calldata _discountProof, // [discountCodeProof, discountData, merkleRoot, merkleProof...]
        bytes memory _providerSignature,
        string calldata _cid
    ) internal {
        require(_planProof.length >= 4, "!INVALID(planProof)");

        Subscription storage subscription = subscriptions[_subscriptionId];

        require(subscription.renewAt == 0 || subscription.renewAt > uint32(block.timestamp), "!NEED_RENEWAL");
        require(subscription.status == SubscriptionStatus.Active ||
            subscription.status == SubscriptionStatus.Trialing, "!INVALID(status)");

        // confirms merkleroots are in fact the ones provider committed to
        address provider;
        if (_discountProof.length >= 3) {
            provider = _verifyMerkleRoots(_planProof[0], _nonce, _planProof[3], _discountProof[2], _providerSignature);
        } else {
            provider = _verifyMerkleRoots(_planProof[0], _nonce, _planProof[3], 0, _providerSignature);
        }

        // confirms plan data is included in merkle root
        require(_verifyPlanProof(_planProof), "!INVALID(planProof)");

        // decode planData bytes32 into PlanInfo
        PlanInfo memory newPlanInfo = _parsePlanData(_planProof[2]);

        require(subscription.provider == provider, "!INVALID(provider)");

        subscription.cid = _cid;

        if (subscription.discountId == 0 && _discountProof.length >= 3 && _discountProof[0] > 0) {
            (
            subscription.discountId,
            subscription.discountData
            ) = _verifyDiscountProof(ownerOf(_subscriptionId), subscription.provider,
                newPlanInfo.planId, _discountProof);
        }

        if (subscription.planId != newPlanInfo.planId) {
            require(subscriptionPlans.getPlanStatus(provider, newPlanInfo.planId) ==
                ICaskSubscriptionPlans.PlanStatus.Enabled, "!NOT_ENABLED");
            _performPlanChange(_subscriptionId, newPlanInfo, _planProof[2]);
        }
    }

    function _performPlanChange(
        uint256 _subscriptionId,
        PlanInfo memory _newPlanInfo,
        bytes32 _planData
    ) internal {
        Subscription storage subscription = subscriptions[_subscriptionId];

        PlanInfo memory currentPlanInfo = _parsePlanData(subscription.planData);

        if (subscription.status == SubscriptionStatus.Trialing) { // still in trial, just change now

            // adjust renewal based on new plan trial length
            subscription.renewAt = subscription.renewAt - currentPlanInfo.freeTrial + _newPlanInfo.freeTrial;

            // if new plan trial length would have caused trial to already be over, end trial as of now
            // subscription will be charged and converted to active during next keeper run
            if (subscription.renewAt <= uint32(block.timestamp)) {
                subscription.renewAt = uint32(block.timestamp);
            }

            _swapPlan(_subscriptionId, _newPlanInfo, _planData);

        } else if (_newPlanInfo.price / _newPlanInfo.period ==
            currentPlanInfo.price / currentPlanInfo.period)
        { // straight swap

            _swapPlan(_subscriptionId, _newPlanInfo, _planData);

        } else if (_newPlanInfo.price / _newPlanInfo.period >
            currentPlanInfo.price / currentPlanInfo.period)
        { // upgrade

            _upgradePlan(_subscriptionId, currentPlanInfo, _newPlanInfo, _planData);

        } else { // downgrade - to take affect at next renewal

            _scheduleSwapPlan(_subscriptionId, _newPlanInfo.planId, _planData);
        }
    }

    function _verifyDiscountProof(
        address _consumer,
        address _provider,
        uint32 _planId,
        bytes32[] calldata _discountProof // [discountValidator, discountData, merkleRoot, merkleProof...]
    ) internal returns(bytes32, bytes32) {
        if (_discountProof[0] > 0) {
            bytes32 discountId = subscriptionPlans.verifyAndConsumeDiscount(_consumer, _provider,
                _planId, _discountProof);
            if (discountId > 0)
            {
                return (discountId, _discountProof[1]);
            }
        }
        return (0,0);
    }

    function _verifyPlanProof(
        bytes32[] calldata _planProof // [provider, ref, planData, merkleRoot, merkleProof...]
    ) internal view returns(bool) {
        return subscriptionPlans.verifyPlan(_planProof[2], _planProof[3], _planProof[4:]);
    }

    function _generateSubscriptionId(
        bytes32 _providerAddr,
        bytes32 _ref,
        bytes32 _planData
    ) internal view returns(uint256) {
        return uint256(keccak256(abi.encodePacked(_msgSender(), _providerAddr,
            _planData, _ref, block.number, block.timestamp)));
    }

    function _parsePlanData(
        bytes32 _planData
    ) internal pure returns(PlanInfo memory) {
        bytes1 options = bytes1(_planData << 248);
        return PlanInfo({
            price: uint256(_planData >> 160),
            planId: uint32(bytes4(_planData << 96)),
            period: uint32(bytes4(_planData << 128)),
            freeTrial: uint32(bytes4(_planData << 160)),
            maxActive: uint32(bytes4(_planData << 192)),
            minPeriods: uint16(bytes2(_planData << 224)),
            gracePeriod: uint8(bytes1(_planData << 240)),
            canPause: options & 0x01 == 0x01,
            canTransfer: options & 0x02 == 0x02
        });
    }

    function _parseNetworkData(
        bytes32 _networkData
    ) internal pure returns(NetworkInfo memory) {
        return NetworkInfo({
            network: address(bytes20(_networkData)),
            feeBps: uint16(bytes2(_networkData << 160))
        });
    }

    function _scheduleSwapPlan(
        uint256 _subscriptionId,
        uint32 newPlanId,
        bytes32 _newPlanData
    ) internal {
        Subscription storage subscription = subscriptions[_subscriptionId];

        pendingPlanChanges[_subscriptionId] = _newPlanData;

        emit SubscriptionPendingChangePlan(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
            subscription.ref, subscription.planId, newPlanId);
    }

    function _swapPlan(
        uint256 _subscriptionId,
        PlanInfo memory _newPlanInfo,
        bytes32 _newPlanData
    ) internal {
        Subscription storage subscription = subscriptions[_subscriptionId];

        emit SubscriptionChangedPlan(ownerOf(_subscriptionId), subscription.provider, _subscriptionId,
            subscription.ref, subscription.planId, _newPlanInfo.planId, subscription.discountId);

        if (_newPlanInfo.minPeriods > 0) {
            subscription.minTermAt = uint32(block.timestamp + (_newPlanInfo.period * _newPlanInfo.minPeriods));
        }

        subscription.planId = _newPlanInfo.planId;
        subscription.planData = _newPlanData;
    }

    function _upgradePlan(
        uint256 _subscriptionId,
        PlanInfo memory _currentPlanInfo,
        PlanInfo memory _newPlanInfo,
        bytes32 _newPlanData
    ) internal {
        Subscription storage subscription = subscriptions[_subscriptionId];

        _swapPlan(_subscriptionId, _newPlanInfo, _newPlanData);

        if (_currentPlanInfo.price == 0 && _newPlanInfo.price != 0) {
            // coming from free plan, no prorate
            subscription.renewAt = uint32(block.timestamp);
            subscriptionManager.renewSubscription(_subscriptionId); // register paid plan with manager
            require(subscription.status == SubscriptionStatus.Active, "!UNPROCESSABLE"); // make sure payment processed
        } else {
            // prorated payment now - next renewal will charge new price
            uint256 newAmount = ((_newPlanInfo.price / _newPlanInfo.period) -
                (_currentPlanInfo.price / _currentPlanInfo.period)) *
                (subscription.renewAt - uint32(block.timestamp));
            require(subscriptionManager.processSinglePayment(ownerOf(_subscriptionId), subscription.provider,
                _subscriptionId, newAmount), "!UNPROCESSABLE");
        }

    }


    /************************** ADMIN FUNCTIONS **************************/

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

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

    function setManager(
        address _subscriptionManager
    ) external onlyOwner {
        subscriptionManager = ICaskSubscriptionManager(_subscriptionManager);
    }

    function setTrustedForwarder(
        address _forwarder
    ) external onlyOwner {
        _setTrustedForwarder(_forwarder);
    }

    function _verifyMerkleRoots(
        bytes32 providerAddr,
        uint256 _nonce,
        bytes32 _planMerkleRoot,
        bytes32 _discountMerkleRoot,
        bytes memory _providerSignature
    ) internal view returns (address) {
        address recovered = keccak256(abi.encode(_nonce, _planMerkleRoot, _discountMerkleRoot))
            .toEthSignedMessageHash()
            .recover(_providerSignature);
        require(address(bytes20(providerAddr << 96)) == recovered, "!INVALID(proof)");
        require(_nonce == subscriptionPlans.getProviderProfile(recovered).nonce, "!PROVIDER_NONCE");
        return recovered;
    }

    function _verifyNetworkData(
        bytes32 _networkData,
        bytes memory _networkSignature
    ) internal pure returns (address) {
        address network = keccak256(abi.encode(_networkData))
            .toEthSignedMessageHash()
            .recover(_networkSignature);
        NetworkInfo memory networkInfo = _parseNetworkData(_networkData);
        require(networkInfo.network == network, "!INVALID(network)");
        return network;
    }

}

File 2 of 20 : ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
    using AddressUpgradeable for address;
    using StringsUpgradeable for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
        return
            interfaceId == type(IERC721Upgradeable).interfaceId ||
            interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
    uint256[44] private __gap;
}

File 3 of 20 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}

File 4 of 20 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @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 __Pausable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _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());
    }
    uint256[49] private __gap;
}

File 5 of 20 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 6 of 20 : BaseRelayRecipient.sol
// SPDX-License-Identifier: MIT
// solhint-disable no-inline-assembly
pragma solidity >=0.6.9;

import "./interfaces/IRelayRecipient.sol";

/**
 * A base contract to be inherited by any contract that want to receive relayed transactions
 * A subclass must use "_msgSender()" instead of "msg.sender"
 */
abstract contract BaseRelayRecipient is IRelayRecipient {

    /*
     * Forwarder singleton we accept calls from
     */
    address private _trustedForwarder;

    function trustedForwarder() public virtual view returns (address){
        return _trustedForwarder;
    }

    function _setTrustedForwarder(address _forwarder) internal {
        _trustedForwarder = _forwarder;
    }

    function isTrustedForwarder(address forwarder) public virtual override view returns(bool) {
        return forwarder == _trustedForwarder;
    }

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, return the original sender.
     * otherwise, return `msg.sender`.
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal override virtual view returns (address ret) {
        if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // so we trust that the last bytes of msg.data are the verified sender address.
            // extract sender address from the end of msg.data
            assembly {
                ret := shr(96,calldataload(sub(calldatasize(),20)))
            }
        } else {
            ret = msg.sender;
        }
    }

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise (if the call was made directly and not through the forwarder), return `msg.data`
     * should be used in the contract instead of msg.data, where this difference matters.
     */
    function _msgData() internal override virtual view returns (bytes calldata ret) {
        if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
            return msg.data[0:msg.data.length-20];
        } else {
            return msg.data;
        }
    }
}

File 7 of 20 : ICaskSubscriptionManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ICaskSubscriptionManager {

    enum CheckType {
        None,
        Active,
        PastDue
    }

    function queueItem(CheckType _checkType, uint32 _bucket, uint256 _idx) external view returns(uint256);

    function queueSize(CheckType _checkType, uint32 _bucket) external view returns(uint256);

    function queuePosition(CheckType _checkType) external view returns(uint32);

    function processSinglePayment(address _consumer, address _provider,
        uint256 _subscriptionId, uint256 _value) external returns(bool);

    function renewSubscription(uint256 _subscriptionId) external;

    /** @dev Emitted when the keeper job performs renewals. */
    event SubscriptionManagerReport(uint256 limit, uint256 renewals, uint256 depth, CheckType checkType,
        uint256 queueRemaining, uint32 currentBucket);

    /** @dev Emitted when manager parameters are changed. */
    event SetParameters();
}

File 8 of 20 : ICaskSubscriptions.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "./ICaskSubscriptionManager.sol";

interface ICaskSubscriptions is IERC721Upgradeable {

    enum SubscriptionStatus {
        None,
        Trialing,
        Active,
        Paused,
        Canceled,
        PastDue,
        PendingPause
    }

    enum ManagerCommand {
        None,
        PlanChange,
        Cancel,
        PastDue,
        Renew,
        ClearDiscount,
        Pause
    }

    struct Subscription {
        bytes32 planData;
        bytes32 networkData;
        bytes32 discountId;
        bytes32 discountData;
        bytes32 ref;
        address provider;
        SubscriptionStatus status;
        uint32 planId;
        uint32 createdAt;
        uint32 renewAt;
        uint32 minTermAt;
        uint32 cancelAt;
        string cid;
        string dataCid;
    }

    struct PlanInfo {
        uint256 price;
        uint32 planId;
        uint32 period;
        uint32 freeTrial;
        uint32 maxActive;
        uint16 minPeriods;
        uint8 gracePeriod;
        bool canPause;
        bool canTransfer;
    }

    struct NetworkInfo {
        address network;
        uint16 feeBps;
    }

    /************************** SUBSCRIPTION INSTANCE METHODS **************************/

    function createSubscription(
        uint256 _nonce,
        bytes32[] calldata _planProof,
        bytes32[] calldata _discountProof,
        uint32 _cancelAt,
        bytes memory _providerSignature,
        string calldata _cid
    ) external;

    function createNetworkSubscription(
        uint256 _nonce,
        bytes32[] calldata _planProof,
        bytes32[] calldata _discountProof,
        bytes32 _networkData,
        uint32 _cancelAt,
        bytes memory _providerSignature,
        bytes memory _networkSignature,
        string calldata _cid
    ) external;

    function changeSubscriptionPlan(
        uint256 _subscriptionId,
        uint256 _nonce,
        bytes32[] calldata _planProof,
        bytes32[] calldata _discountProof,
        bytes memory _providerSignature,
        string calldata _cid
    ) external;

    function attachData(uint256 _subscriptionId, string calldata _dataCid) external;

    function pauseSubscription(uint256 _subscriptionId) external;

    function resumeSubscription(uint256 _subscriptionId) external;

    function cancelSubscription(uint256 _subscriptionId, uint32 _cancelAt) external;

    function managerCommand(uint256 _subscriptionId, ManagerCommand _command) external;

    function getSubscription(uint256 _subscriptionId) external view returns
        (Subscription memory subscription, address currentOwner);

    function getConsumerSubscription(address _consumer, uint256 _idx) external view returns(uint256);

    function getConsumerSubscriptionCount(address _consumer) external view returns (uint256);

    function getProviderSubscription(address _provider, uint256 _idx) external view returns(uint256);

    function getProviderSubscriptionCount(address _provider, bool _includeCanceled, uint32 _planId) external view returns (uint256);

    function getActiveSubscriptionCount(address _consumer, address _provider, uint32 _planId) external view returns(uint256);

    function getPendingPlanChange(uint256 _subscriptionId) external view returns (bytes32);


    /************************** SUBSCRIPTION EVENTS **************************/

    /** @dev Emitted when `consumer` subscribes to `provider` plan `planId` */
    event SubscriptionCreated(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId, bytes32 discountId);

    /** @dev Emitted when `consumer` changes the plan to `provider` on subscription `subscriptionId` */
    event SubscriptionChangedPlan(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 prevPlanId, uint32 planId, bytes32 discountId);

    /** @dev Emitted when `consumer` changes the plan to `provider` on subscription `subscriptionId` */
    event SubscriptionPendingChangePlan(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 prevPlanId, uint32 planId);

    /** @dev Emitted when `consumer` initiates a pause of the subscription to `provider` on subscription `subscriptionId` */
    event SubscriptionPendingPause(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId);

    /** @dev Emitted when a pending pause subscription attempts to renew but is paused */
    event SubscriptionPaused(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId);

    /** @dev Emitted when `consumer` resumes the subscription to `provider` on subscription `subscriptionId` */
    event SubscriptionResumed(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId);

    /** @dev Emitted when `consumer` unsubscribes to `provider` on subscription `subscriptionId` */
    event SubscriptionPendingCancel(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId, uint32 cancelAt);

    /** @dev Emitted when `consumer` has canceled and the current period is over on subscription `subscriptionId` */
    event SubscriptionCanceled(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId);

    /** @dev Emitted when `consumer` successfully renews to `provider` on subscription `subscriptionId` */
    event SubscriptionRenewed(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId);

    /** @dev Emitted when `consumer` subscription trial ends and goes active to `provider`
     * on subscription `subscriptionId`
     */
    event SubscriptionTrialEnded(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId);

    /** @dev Emitted when `consumer` renewal fails to `provider` on subscription `subscriptionId` */
    event SubscriptionPastDue(address indexed consumer, address indexed provider,
        uint256 indexed subscriptionId, bytes32 ref, uint32 planId);

}

File 9 of 20 : ICaskSubscriptionPlans.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ICaskSubscriptionPlans {

    enum PlanStatus {
        Enabled,
        Disabled,
        EndOfLife
    }

    enum DiscountType {
        None,
        Code,
        ERC20
    }

    struct Discount {
        uint256 value;
        uint32 validAfter;
        uint32 expiresAt;
        uint32 maxRedemptions;
        uint32 planId;
        uint16 applyPeriods;
        DiscountType discountType;
        bool isFixed;
    }

    struct Provider {
        address paymentAddress;
        uint256 nonce;
        string cid;
    }

    function setProviderProfile(address _paymentAddress, string calldata _cid, uint256 _nonce) external;

    function getProviderProfile(address _provider) external view returns(Provider memory);

    function getPlanStatus(address _provider, uint32 _planId) external view returns (PlanStatus);

    function getPlanEOL(address _provider, uint32 _planId) external view returns (uint32);

    function disablePlan(uint32 _planId) external;

    function enablePlan(uint32 _planId) external;

    function retirePlan(uint32 _planId, uint32 _retireAt) external;

    function verifyPlan(bytes32 _planData, bytes32 _merkleRoot,
        bytes32[] calldata _merkleProof) external view returns(bool);

    function getDiscountRedemptions(address _provider, uint32 _planId,
        bytes32 _discountId) external view returns(uint256);

    function verifyAndConsumeDiscount(address _consumer, address _provider, uint32 _planId,
        bytes32[] calldata _discountProof) external returns(bytes32);

    function verifyDiscount(address _consumer, address _provider, uint32 _planId,
        bytes32[] calldata _discountProof) external returns(bytes32);

    function erc20DiscountCurrentlyApplies(address _consumer, bytes32 _discountValidator) external returns(bool);


    /** @dev Emitted when `provider` sets their profile info */
    event ProviderSetProfile(address indexed provider, address indexed paymentAddress, uint256 nonce, string cid);

    /** @dev Emitted when `provider` disables a subscription plan */
    event PlanDisabled(address indexed provider, uint32 indexed planId);

    /** @dev Emitted when `provider` enables a subscription plan */
    event PlanEnabled(address indexed provider, uint32 indexed planId);

    /** @dev Emitted when `provider` end-of-lifes a subscription plan */
    event PlanRetired(address indexed provider, uint32 indexed planId, uint32 retireAt);

}

File 10 of 20 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @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;
}

File 11 of 20 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @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);
}

File 12 of 20 : IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 13 of 20 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    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 Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 14 of 20 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 15 of 20 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 16 of 20 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 17 of 20 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since 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.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
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() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 18 of 20 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 19 of 20 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 20 of 20 : IRelayRecipient.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

/**
 * a contract must implement this interface in order to support relayed transaction.
 * It is better to inherit the BaseRelayRecipient as its implementation.
 */
abstract contract IRelayRecipient {

    /**
     * return if the forwarder is trusted to forward relayed transactions to us.
     * the forwarder is required to verify the sender's signature, and verify
     * the call is not a replay.
     */
    function isTrustedForwarder(address forwarder) public virtual view returns(bool);

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
     * of the msg.data.
     * otherwise, return `msg.sender`
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal virtual view returns (address);

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise (if the call was made directly and not through the forwarder), return `msg.data`
     * should be used in the contract instead of msg.data, where this difference matters.
     */
    function _msgData() internal virtual view returns (bytes calldata);

    function versionRecipient() external virtual view returns (string memory);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"prevPlanId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"discountId","type":"bytes32"}],"name":"SubscriptionChangedPlan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"discountId","type":"bytes32"}],"name":"SubscriptionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionPastDue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"cancelAt","type":"uint32"}],"name":"SubscriptionPendingCancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"prevPlanId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionPendingChangePlan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionPendingPause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionRenewed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionResumed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"consumer","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"ref","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"SubscriptionTrialEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"},{"internalType":"string","name":"_dataCid","type":"string"}],"name":"attachData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"},{"internalType":"uint32","name":"_cancelAt","type":"uint32"}],"name":"cancelSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"},{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes32[]","name":"_planProof","type":"bytes32[]"},{"internalType":"bytes32[]","name":"_discountProof","type":"bytes32[]"},{"internalType":"bytes","name":"_providerSignature","type":"bytes"},{"internalType":"string","name":"_cid","type":"string"}],"name":"changeSubscriptionPlan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes32[]","name":"_planProof","type":"bytes32[]"},{"internalType":"bytes32[]","name":"_discountProof","type":"bytes32[]"},{"internalType":"bytes32","name":"_networkData","type":"bytes32"},{"internalType":"uint32","name":"_cancelAt","type":"uint32"},{"internalType":"bytes","name":"_providerSignature","type":"bytes"},{"internalType":"bytes","name":"_networkSignature","type":"bytes"},{"internalType":"string","name":"_cid","type":"string"}],"name":"createNetworkSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes32[]","name":"_planProof","type":"bytes32[]"},{"internalType":"bytes32[]","name":"_discountProof","type":"bytes32[]"},{"internalType":"uint32","name":"_cancelAt","type":"uint32"},{"internalType":"bytes","name":"_providerSignature","type":"bytes"},{"internalType":"string","name":"_cid","type":"string"}],"name":"createSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_consumer","type":"address"},{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint32","name":"_planId","type":"uint32"}],"name":"getActiveSubscriptionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_consumer","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"getConsumerSubscription","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_consumer","type":"address"}],"name":"getConsumerSubscriptionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"}],"name":"getPendingPlanChange","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"getProviderSubscription","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_provider","type":"address"},{"internalType":"bool","name":"_includeCanceled","type":"bool"},{"internalType":"uint32","name":"_planId","type":"uint32"}],"name":"getProviderSubscriptionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"}],"name":"getSubscription","outputs":[{"components":[{"internalType":"bytes32","name":"planData","type":"bytes32"},{"internalType":"bytes32","name":"networkData","type":"bytes32"},{"internalType":"bytes32","name":"discountId","type":"bytes32"},{"internalType":"bytes32","name":"discountData","type":"bytes32"},{"internalType":"bytes32","name":"ref","type":"bytes32"},{"internalType":"address","name":"provider","type":"address"},{"internalType":"enum ICaskSubscriptions.SubscriptionStatus","name":"status","type":"uint8"},{"internalType":"uint32","name":"planId","type":"uint32"},{"internalType":"uint32","name":"createdAt","type":"uint32"},{"internalType":"uint32","name":"renewAt","type":"uint32"},{"internalType":"uint32","name":"minTermAt","type":"uint32"},{"internalType":"uint32","name":"cancelAt","type":"uint32"},{"internalType":"string","name":"cid","type":"string"},{"internalType":"string","name":"dataCid","type":"string"}],"internalType":"struct ICaskSubscriptions.Subscription","name":"subscription","type":"tuple"},{"internalType":"address","name":"currentOwner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subscriptionPlans","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"},{"internalType":"enum ICaskSubscriptions.ManagerCommand","name":"_command","type":"uint8"}],"name":"managerCommand","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"}],"name":"pauseSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"}],"name":"resumeSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subscriptionManager","type":"address"}],"name":"setManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_forwarder","type":"address"}],"name":"setTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"subscriptionManager","outputs":[{"internalType":"contract ICaskSubscriptionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"subscriptionPlans","outputs":[{"internalType":"contract ICaskSubscriptionPlans","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_subscriptionId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"versionRecipient","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]

60806040523480156200001157600080fd5b50600054610100900460ff166200002f5760005460ff161562000039565b62000039620000de565b620000a15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054610100900460ff16158015620000c4576000805461ffff19166101011790555b8015620000d7576000805461ff00191690555b5062000102565b6000620000f630620000fc60201b620029cc1760201c565b15905090565b3b151590565b615eaf80620001126000396000f3fe608060405234801561001057600080fd5b506004361061025e5760003560e01c80637df7b2aa11610146578063b88d4fde116100c3578063d0ebdbe711610087578063d0ebdbe714610557578063d67dc0de1461056a578063da742228146105b3578063dc311dd3146105c6578063e985e9c5146105e7578063f2fde38b1461062357600080fd5b8063b88d4fde146104ea578063bf158fd2146104fd578063c4d66de814610510578063c86e695414610523578063c87b56dd1461054457600080fd5b80638fe17b161161010a5780638fe17b1614610496578063925fa591146104a957806395d89b41146104bc578063a22cb465146104c4578063ac58e37b146104d757600080fd5b80637df7b2aa14610444578063825527ff146104575780638456cb591461046a578063876bebbb146104725780638da5cb5b1461048557600080fd5b806342842e0e116101df5780635c975abb116101a35780635c975abb146103e75780636352211e146103f257806370a0823114610405578063715018a61461041857806374c14439146104205780637da0a8771461043357600080fd5b806342842e0e1461036b57806345041a461461037e578063486ff0cd146103915780634d5106ae146103b2578063572b6c05146103c557600080fd5b806323b872dd1161022657806323b872dd146102f3578063291b9a3f1461030657806336fd3a8a1461033d5780633f4ba83a1461035057806341f23f0a1461035857600080fd5b806301ffc9a714610263578063023a584e1461028b57806306fdde03146102a0578063081812fc146102b5578063095ea7b3146102e0575b600080fd5b610276610271366004614fff565b610636565b60405190151581526020015b60405180910390f35b61029e61029936600461501c565b610688565b005b6102a8610ad4565b604051610282919061508d565b6102c86102c336600461501c565b610b66565b6040516001600160a01b039091168152602001610282565b61029e6102ee3660046150b5565b610bfb565b61029e6103013660046150e1565b610d23565b61032f610314366004615122565b6001600160a01b0316600090815260fe602052604090205490565b604051908152602001610282565b61032f61034b3660046150b5565b610d5b565b61029e610d98565b61029e61036636600461501c565b610deb565b61029e6103793660046150e1565b611084565b61029e61038c366004615181565b61109f565b6040805180820190915260058152640322e322e360dc1b60208201526102a8565b61029e6103c0366004615319565b6111b7565b6102766103d3366004615122565b6065546001600160a01b0391821691161490565b60ca5460ff16610276565b6102c861040036600461501c565b6111f7565b61032f610413366004615122565b61126e565b61029e6112f5565b61032f61042e366004615405565b611348565b6065546001600160a01b03166102c8565b61029e61045236600461544c565b6113d0565b61029e610465366004615480565b611c29565b61029e611c8d565b61032f6104803660046150b5565b611cde565b6098546001600160a01b03166102c8565b60fd546102c8906001600160a01b031681565b61029e6104b7366004615590565b611d09565b6102a86120c0565b61029e6104d23660046155bc565b6120cf565b61029e6104e53660046155ea565b6120e1565b61029e6104f8366004615678565b612156565b60fc546102c8906001600160a01b031681565b61029e61051e366004615122565b61218f565b61032f61053136600461501c565b6000908152610100602052604090205490565b6102a861055236600461501c565b6122c7565b61029e610565366004615122565b612581565b61032f6105783660046156e4565b6001600160a01b0392831660009081526101046020908152604080832094909516825292835283812063ffffffff9290921681529152205490565b61029e6105c1366004615122565b6125ec565b6105d96105d436600461501c565b612656565b60405161028292919061574c565b6102766105f536600461588a565b6001600160a01b039182166000908152606b6020908152604080832093909416825291909152205460ff1690565b61029e610631366004615122565b612915565b60006001600160e01b031982166380ac58cd60e01b148061066757506001600160e01b03198216635b5e139f60e01b145b8061068257506301ffc9a760e01b6001600160e01b03198316145b92915050565b80610692816111f7565b6001600160a01b03166106a36129d2565b6001600160a01b0316146106d25760405162461bcd60e51b81526004016106c9906158b8565b60405180910390fd5b60ca5460ff16156106f55760405162461bcd60e51b81526004016106c9906158d7565b600082815260ff6020526040902060036005820154600160a01b900460ff16600681111561072557610725615714565b1480610750575060066005820154600160a01b900460ff16600681111561074e5761074e615714565b145b61078a5760405162461bcd60e51b815260206004820152600b60248201526a085393d517d4105554d15160aa1b60448201526064016106c9565b600581015483906001600160a01b03166107a3826111f7565b6004840154600585015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f7ee0fc3eab7021686f891346ebbf5bab192d6f9995fcc66021f4551888dc1481910160405180910390a460066005820154600160a01b900460ff16600681111561082157610821615714565b141561083f57600501805460ff60a01b1916600160a11b1790555050565b600061084e82600001546129e1565b9050806080015163ffffffff16600014806108a15750608081015160058301546001600160a01b03166000908152610103602090815260408083208286015163ffffffff90811685529252909120549116115b6108db5760405162461bcd60e51b815260206004820152600b60248201526a214d41585f41435449564560a81b60448201526064016106c9565b600582018054600160a11b60ff60a01b198216179091556001600160a01b031660009081526101026020526040812080546001929061091b908490615917565b909155505060058201546001600160a01b038116600090815261010360209081526040808320600160a81b90940463ffffffff168352929052908120805460019290610968908490615917565b9091555060019050610104600061097e876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff1681529252812080549091906109d1908490615917565b9091555050600682015463ffffffff42811691161015610a035760068201805463ffffffff19164263ffffffff161790555b60fc5460405163d71bb37b60e01b8152600481018690526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b158015610a4957600080fd5b505af1158015610a5d573d6000803e3d6000fd5b5060029250610a6a915050565b6005830154600160a01b900460ff166006811115610a8a57610a8a615714565b14610acd5760405162461bcd60e51b815260206004820152601360248201527221494e53554646494349454e545f46554e445360681b60448201526064016106c9565b50505b5050565b606060668054610ae39061592f565b80601f0160208091040260200160405190810160405280929190818152602001828054610b0f9061592f565b8015610b5c5780601f10610b3157610100808354040283529160200191610b5c565b820191906000526020600020905b815481529060010190602001808311610b3f57829003601f168201915b5050505050905090565b6000818152606860205260408120546001600160a01b0316610bdf5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106c9565b506000908152606a60205260409020546001600160a01b031690565b6000610c06826111f7565b9050806001600160a01b0316836001600160a01b03161415610c745760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106c9565b806001600160a01b0316610c866129d2565b6001600160a01b03161480610ca25750610ca2816105f56129d2565b610d145760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106c9565b610d1e8383612abc565b505050565b610d34610d2e6129d2565b82612b2a565b610d505760405162461bcd60e51b81526004016106c99061596a565b610d1e838383612c21565b6001600160a01b038216600090815260fe60205260408120805483908110610d8557610d856159bb565b9060005260206000200154905092915050565b610da06129d2565b6001600160a01b0316610dbb6098546001600160a01b031690565b6001600160a01b031614610de15760405162461bcd60e51b81526004016106c9906159d1565b610de9612dcc565b565b80610df5816111f7565b6001600160a01b0316610e066129d2565b6001600160a01b03161480610e445750600081815260ff60205260409020600501546001600160a01b0316610e396129d2565b6001600160a01b0316145b610e605760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff1615610e835760405162461bcd60e51b81526004016106c9906158d7565b600082815260ff6020526040902060036005820154600160a01b900460ff166006811115610eb357610eb3615714565b14158015610ee05750600580820154600160a01b900460ff166006811115610edd57610edd615714565b14155b8015610f0c575060046005820154600160a01b900460ff166006811115610f0957610f09615714565b14155b8015610f38575060016005820154600160a01b900460ff166006811115610f3557610f35615714565b14155b610f545760405162461bcd60e51b81526004016106c990615a06565b6006810154600160201b900463ffffffff161580610f885750600681015463ffffffff600160201b90910481164290911610155b610fa45760405162461bcd60e51b81526004016106c990615a30565b6000610fb382600001546129e1565b90508060e00151610ff65760405162461bcd60e51b815260206004820152600d60248201526c214e4f545f5041555341424c4560981b60448201526064016106c9565b600582018054600360a11b60ff60a01b1982161790915584906001600160a01b0316611021826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f3b1ababbfb41865093a096e886e08d3058f1adbce6c29e7be7ed6fd16b70802891015b60405180910390a450505050565b610d1e83838360405180602001604052806000815250612156565b826110a9816111f7565b6001600160a01b03166110ba6129d2565b6001600160a01b031614806110f85750600081815260ff60205260409020600501546001600160a01b03166110ed6129d2565b6001600160a01b0316145b6111145760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff16156111375760405162461bcd60e51b81526004016106c9906158d7565b600084815260ff6020526040902060046005820154600160a01b900460ff16600681111561116757611167615714565b14156111a15760405162461bcd60e51b81526020600482015260096024820152680850d05390d153115160ba1b60448201526064016106c9565b6111af600882018585614edc565b505050505050565b60ca5460ff16156111da5760405162461bcd60e51b81526004016106c9906158d7565b6111eb898989898989898989612e65565b50505050505050505050565b6000818152606860205260408120546001600160a01b0316806106825760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106c9565b60006001600160a01b0382166112d95760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106c9565b506001600160a01b031660009081526069602052604090205490565b6112fd6129d2565b6001600160a01b03166113186098546001600160a01b031690565b6001600160a01b03161461133e5760405162461bcd60e51b81526004016106c9906159d1565b610de9600061360e565b6000821561137057506001600160a01b038316600090815261010160205260409020546113c9565b63ffffffff8216156113ad57506001600160a01b03831660009081526101036020908152604080832063ffffffff851684529091529020546113c9565b506001600160a01b038316600090815261010260205260409020545b9392505050565b60fc546001600160a01b03166113e46129d2565b6001600160a01b03161461140a5760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff161561142d5760405162461bcd60e51b81526004016106c9906158d7565b600082815260ff6020526040902042600183600681111561145057611450615714565b14156115e95760008481526101006020526040902054806114b35760405162461bcd60e51b815260206004820152601960248201527f21494e56414c49442870656e64696e67506c616e44617461290000000000000060448201526064016106c9565b60006114be826129e1565b600585015490915086906001600160a01b03166114da826111f7565b6004870154600588015460208087015160028b01546040805195865263ffffffff600160a81b90950485169386019390935292169083015260608201526001600160a01b0391909116907fe17e61be0a4aac2f0b6fece72cedc2ab9ca554634d5af864a9282095206a0c2b9060800160405180910390a4602081015160058501805463ffffffff909216600160a81b0263ffffffff60a81b1990921691909117905581845560a081015161ffff16156115d2578060a0015161ffff1681604001516115a59190615a53565b6115af9084615a7f565b8460060160046101000a81548163ffffffff021916908363ffffffff1602179055505b505060008481526101006020526040812055610acd565b60028360068111156115fd576115fd615714565b14156117db57600582018054600160a21b60ff60a01b198216179091556001600160a01b0316600090815261010260205260408120805460019290611643908490615aa7565b909155505060058201546001600160a01b038116600090815261010360209081526040808320600160a81b90940463ffffffff168352929052908120805460019290611690908490615aa7565b9091555060009050610104816116a5876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff1681529252902054111561175857600161010460006116ff876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff168152925281208054909190611752908490615aa7565b90915550505b600582015484906001600160a01b0316611771826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f58e4414596fd750dbb9dabfe65b97bf5add2061f5902f34e2b82a9c25bd79f98910160405180910390a46117d684613660565b610acd565b60068360068111156117ef576117ef615714565b14156119c557600582018054600360a01b60ff60a01b198216179091556001600160a01b0316600090815261010260205260408120805460019290611835908490615aa7565b909155505060058201546001600160a01b038116600090815261010360209081526040808320600160a81b90940463ffffffff168352929052908120805460019290611882908490615aa7565b909155506000905061010481611897876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff1681529252902054111561194a57600161010460006118f1876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff168152925281208054909190611944908490615aa7565b90915550505b600582015484906001600160a01b0316611963826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f7afd3b59e582bb56b590409b808e910ae787056cb10b682b9bdefa44c8eb940d91015b60405180910390a4610acd565b60038360068111156119d9576119d9615714565b1415611a6357600582018054600560a01b60ff60a01b1982161790915584906001600160a01b0316611a0a826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f44abb4f4529fdbcacc1ee98eef9318eaf9a12044d6925a2dc2c702959d9352f191016119b8565b6004836006811115611a7757611a77615714565b1415611bfb576000611a8c83600001546129e1565b905060016005840154600160a01b900460ff166006811115611ab057611ab0615714565b1415611b2c57600583015485906001600160a01b0316611acf826111f7565b6004860154600587015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917ff42e506093cb49dad3d3349cf7a2b390140be665daecb2c820e903afd12b1df7910160405180910390a45b60408101516006840154611b46919063ffffffff16615a7f565b60068401805463ffffffff191663ffffffff9283169081179091559083161015611b805760058301805460ff60a01b1916600160a11b1790555b600583015485906001600160a01b0316611b99826111f7565b6004860154600587015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917fcdd2eee203a384f2c6e81f39021f7e3ebef3a21ccd0d0f6dd117387ab61b6b54910160405180910390a450610acd565b6005836006811115611c0f57611c0f615714565b1415610acd57600060028301819055600383015550505050565b60ca5460ff1615611c4c5760405162461bcd60e51b81526004016106c9906158d7565b6000611c5f8c8c8c8c8c8b8b8a8a612e65565b9050611c6b8785613707565b50600090815260ff602052604090206001019590955550505050505050505050565b611c956129d2565b6001600160a01b0316611cb06098546001600160a01b031690565b6001600160a01b031614611cd65760405162461bcd60e51b81526004016106c9906159d1565b610de961382d565b6001600160a01b038216600090815261010160205260408120805483908110610d8557610d856159bb565b81611d13816111f7565b6001600160a01b0316611d246129d2565b6001600160a01b03161480611d625750600081815260ff60205260409020600501546001600160a01b0316611d576129d2565b6001600160a01b0316145b611d7e5760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff1615611da15760405162461bcd60e51b81526004016106c9906158d7565b600083815260ff6020526040902060046005820154600160a01b900460ff166006811115611dd157611dd1615714565b1415611def5760405162461bcd60e51b81526004016106c990615a06565b4263ffffffff8416611edd57611e04856111f7565b6001600160a01b0316611e156129d2565b6001600160a01b031614611e3b5760405162461bcd60e51b81526004016106c9906158b8565b60068201805463ffffffff60401b1916600160401b63ffffffff871602179055600582015485906001600160a01b0316611e74826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff9081166020840152891682820152516001600160a01b0392909216917fc54424be96a88104b924830a25713de0140a7b7048d7a26370e735b421b057869181900360600190a46120b9565b8063ffffffff168463ffffffff1611611fcc576006820154600160201b900463ffffffff161580611f235750600682015463ffffffff600160201b909104811690821610155b611f3f5760405162461bcd60e51b81526004016106c990615a30565b600682018054600160401b63ffffffff84169081026bffffffff00000000ffffffff199092161717905560fc5460405163d71bb37b60e01b8152600481018790526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b158015611faf57600080fd5b505af1158015611fc3573d6000803e3d6000fd5b505050506120b9565b6006820154600160201b900463ffffffff161580611fff5750600682015463ffffffff600160201b909104811690851610155b61201b5760405162461bcd60e51b81526004016106c990615a30565b60068201805463ffffffff60401b1916600160401b63ffffffff871602179055600582015485906001600160a01b0316612054826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff9081166020840152891682820152516001600160a01b0392909216917fc54424be96a88104b924830a25713de0140a7b7048d7a26370e735b421b057869181900360600190a45b5050505050565b606060678054610ae39061592f565b610ad06120da6129d2565b8383613886565b886120eb816111f7565b6001600160a01b03166120fc6129d2565b6001600160a01b0316146121225760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff16156121455760405162461bcd60e51b81526004016106c9906158d7565b6111eb8a8a8a8a8a8a8a8a8a613955565b6121676121616129d2565b83612b2a565b6121835760405162461bcd60e51b81526004016106c99061596a565b610acd84848484613d1d565b600054610100900460ff166121aa5760005460ff16156121ae565b303b155b6122115760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106c9565b600054610100900460ff16158015612233576000805461ffff19166101011790555b61223b613d50565b612243613d87565b612297604051806040016040528060128152602001714361736b20537562736372697074696f6e7360701b815250604051806040016040528060088152602001674341534b5355425360c01b815250613dbe565b60fd80546001600160a01b0319166001600160a01b0384161790558015610ad0576000805461ff00191690555050565b6000818152606860205260409020546060906001600160a01b03166123465760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106c9565b600082815260ff6020818152604080842081516101c08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004810154608083015260058101546001600160a01b03811660a08401529192909160c0840191600160a01b9091041660068111156123c7576123c7615714565b60068111156123d8576123d8615714565b8152600582015463ffffffff600160a81b820481166020840152600160c81b9091048116604083015260068301548082166060840152600160201b810482166080840152600160401b90041660a082015260078201805460c09092019161243e9061592f565b80601f016020809104026020016040519081016040528092919081815260200182805461246a9061592f565b80156124b75780601f1061248c576101008083540402835291602001916124b7565b820191906000526020600020905b81548152906001019060200180831161249a57829003601f168201915b505050505081526020016008820180546124d09061592f565b80601f01602080910402602001604051908101604052809291908181526020018280546124fc9061592f565b80156125495780601f1061251e57610100808354040283529160200191612549565b820191906000526020600020905b81548152906001019060200180831161252c57829003601f168201915b505050505081525050905080610180015160405160200161256a9190615abe565b604051602081830303815290604052915050919050565b6125896129d2565b6001600160a01b03166125a46098546001600160a01b031690565b6001600160a01b0316146125ca5760405162461bcd60e51b81526004016106c9906159d1565b60fc80546001600160a01b0319166001600160a01b0392909216919091179055565b6125f46129d2565b6001600160a01b031661260f6098546001600160a01b031690565b6001600160a01b0316146126355760405162461bcd60e51b81526004016106c9906159d1565b606580546001600160a01b0319166001600160a01b03831617905550565b50565b604080516101c08101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e0820183905261010082018390526101208201839052610140820183905261016082019290925261018081018290526101a0810191909152600082815260ff6020818152604080842081516101c08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004810154608083015260058101546001600160a01b03811660a08401529192909160c0840191600160a01b90910416600681111561274a5761274a615714565b600681111561275b5761275b615714565b8152600582015463ffffffff600160a81b820481166020840152600160c81b9091048116604083015260068301548082166060840152600160201b810482166080840152600160401b90041660a082015260078201805460c0909201916127c19061592f565b80601f01602080910402602001604051908101604052809291908181526020018280546127ed9061592f565b801561283a5780601f1061280f5761010080835404028352916020019161283a565b820191906000526020600020905b81548152906001019060200180831161281d57829003601f168201915b505050505081526020016008820180546128539061592f565b80601f016020809104026020016040519081016040528092919081815260200182805461287f9061592f565b80156128cc5780601f106128a1576101008083540402835291602001916128cc565b820191906000526020600020905b8154815290600101906020018083116128af57829003601f168201915b50505050508152505091506128f8836000908152606860205260409020546001600160a01b0316151590565b1561290d57612906836111f7565b9050915091565b506000915091565b61291d6129d2565b6001600160a01b03166129386098546001600160a01b031690565b6001600160a01b03161461295e5760405162461bcd60e51b81526004016106c9906159d1565b6001600160a01b0381166129c35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106c9565b6126538161360e565b3b151590565b60006129dc613dff565b905090565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915250604080516101208101825260a083811c8252608084811c63ffffffff908116602080860191909152606087811c8316868801529587901c8216958501959095529385901c90931692820192909252601083901c61ffff1691810191909152600882901c60ff1660c082015260f89190911b600160f81b8181161460e0830152600160f91b9081161461010082015290565b6000818152606a6020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612af1826111f7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152606860205260408120546001600160a01b0316612ba35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106c9565b6000612bae836111f7565b9050806001600160a01b0316846001600160a01b03161480612be95750836001600160a01b0316612bde84610b66565b6001600160a01b0316145b80612c1957506001600160a01b038082166000908152606b602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316612c34826111f7565b6001600160a01b031614612c9c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106c9565b6001600160a01b038216612cfe5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106c9565b612d09838383613e33565b612d14600082612abc565b6001600160a01b0383166000908152606960205260408120805460019290612d3d908490615aa7565b90915550506001600160a01b0382166000908152606960205260408120805460019290612d6b908490615917565b909155505060008181526068602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60ca5460ff16612e155760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106c9565b60ca805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612e486129d2565b6040516001600160a01b03909116815260200160405180910390a1565b60006004881015612eb15760405162461bcd60e51b815260206004820152601660248201527521494e56414c494428706c616e50726f6f664c656e2960501b60448201526064016106c9565b600060038710612f1a57612f138a8a6000818110612ed157612ed16159bb565b905060200201358c8c8c6003818110612eec57612eec6159bb565b905060200201358b8b6002818110612f0657612f066159bb565b9050602002013589613f5d565b9050612f5f565b612f5c8a8a6000818110612f3057612f306159bb565b905060200201358c8c8c6003818110612f4b57612f4b6159bb565b905060200201356000801b89613f5d565b90505b612f698a8a6140ab565b612f855760405162461bcd60e51b81526004016106c990615aed565b6000612fa98b8b6002818110612f9d57612f9d6159bb565b905060200201356129e1565b905060006130038c8c6000818110612fc357612fc36159bb565b905060200201358d8d6001818110612fdd57612fdd6159bb565b905060200201358e8e6002818110612ff757612ff76159bb565b90506020020135614172565b9050816080015163ffffffff1660001480613052575060808201516001600160a01b0384166000908152610103602090815260408083208287015163ffffffff90811685529252909120549116115b61308c5760405162461bcd60e51b815260206004820152600b60248201526a214d41585f41435449564560a81b60448201526064016106c9565b600060fd54602084015160405163b6ab359f60e01b81526001600160a01b03878116600483015263ffffffff909216602482015291169063b6ab359f9060440160206040518083038186803b1580156130e457600080fd5b505afa1580156130f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061311c9190615b1a565b600281111561312d5761312d615714565b146131695760405162461bcd60e51b815260206004820152600c60248201526b085393d517d153905093115160a21b60448201526064016106c9565b61317a6131746129d2565b826141dd565b600081815260ff602090815260409091206005810180549285015163ffffffff16600160a81b02600164ffffffff0160a01b03199093166001600160a01b0387161792909217909155428d8d60018181106131d7576131d76159bb565b60200291909101356004840155508d8d60028181106131f8576131f86159bb565b602002919091013583555060068201805463ffffffff60401b1916600160401b63ffffffff8d1602179055613231600783018989614edc565b5060058201805463ffffffff60c81b1916600160c81b63ffffffff84160217905560a084015161ffff16156132a5578360a0015161ffff1684604001516132789190615a53565b6132829082615a7f565b8260060160046101000a81548163ffffffff021916908363ffffffff1602179055505b83516132d45760058201805460ff60a01b1916600160a11b17905560068201805463ffffffff19169055613356565b606084015163ffffffff16156133295760058201805460ff60a01b1916600160a01b17905560608401516133089082615a7f565b60068301805463ffffffff191663ffffffff92909216919091179055613356565b60058201805460ff60a01b1916600160a11b17905560068201805463ffffffff191663ffffffff83161790555b60fe60006133626129d2565b6001600160a01b03908116825260208083019390935260409182016000908120805460018181018355918352858320018890559189168082526101018552838220805480850182559083528583200188905581526101029093529082208054919290916133d0908490615917565b90915550506001600160a01b0385166000908152610103602090815260408083208783015163ffffffff1684529091528120805460019290613413908490615917565b909155506001905061010460006134286129d2565b6001600160a01b03908116825260208083019390935260409182016000908120918a1681529083528181208884015163ffffffff16825290925281208054909190613474908490615917565b909155506134a39050613486846111f7565b600584015460208701516001600160a01b03909116908f8f6141f7565b6003840155600283015560fc5460405163d71bb37b60e01b8152600481018590526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b1580156134f357600080fd5b505af1158015613507573d6000803e3d6000fd5b5060029250613514915050565b6005830154600160a01b900460ff16600681111561353457613534615714565b148061355f575060016005830154600160a01b900460ff16600681111561355d5761355d615714565b145b61357b5760405162461bcd60e51b81526004016106c990615b3b565b600582015483906001600160a01b0316613594826111f7565b60048501546005860154600287015460408051938452600160a81b90920463ffffffff166020840152908201526001600160a01b0391909116907f9fb45eab820cdd481e286e8c699e1c01031bb833c58f7cfba3ca8d1db6d98d819060600160405180910390a450909d9c50505050505050505050505050565b609880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061366b826111f7565b905061367981600084613e33565b613684600083612abc565b6001600160a01b03811660009081526069602052604081208054600192906136ad908490615aa7565b909155505060008281526068602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60008061378a836137848660405160200161372491815260200190565b60408051601f1981840301815282825280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000084830152603c8085019190915282518085039091018152605c909301909152815191012090565b906142e3565b905060006137ca8560408051808201909152600080825260208201525060408051808201909152606082901c815260509190911c61ffff16602082015290565b9050816001600160a01b031681600001516001600160a01b0316146138255760405162461bcd60e51b815260206004820152601160248201527021494e56414c4944286e6574776f726b2960781b60448201526064016106c9565b509392505050565b60ca5460ff16156138505760405162461bcd60e51b81526004016106c9906158d7565b60ca805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612e486129d2565b816001600160a01b0316836001600160a01b031614156138e85760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106c9565b6001600160a01b038381166000818152606b6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60048610156139765760405162461bcd60e51b81526004016106c990615aed565b600089815260ff60205260409020600681015463ffffffff1615806139a75750600681015463ffffffff4281169116115b6139e35760405162461bcd60e51b815260206004820152600d60248201526c085391515117d491539155d053609a1b60448201526064016106c9565b60026005820154600160a01b900460ff166006811115613a0557613a05615714565b1480613a30575060016005820154600160a01b900460ff166006811115613a2e57613a2e615714565b145b613a4c5760405162461bcd60e51b81526004016106c990615a06565b600060038610613aa857613aa189896000818110613a6c57613a6c6159bb565b905060200201358b8b8b6003818110613a8757613a876159bb565b905060200201358a8a6002818110612f0657612f066159bb565b9050613adc565b613ad989896000818110613abe57613abe6159bb565b905060200201358b8b8b6003818110612f4b57612f4b6159bb565b90505b613ae689896140ab565b613b025760405162461bcd60e51b81526004016106c990615aed565b6000613b1a8a8a6002818110612f9d57612f9d6159bb565b60058401549091506001600160a01b03838116911614613b715760405162461bcd60e51b815260206004820152601260248201527121494e56414c49442870726f76696465722960701b60448201526064016106c9565b613b7f600784018686614edc565b506002830154158015613b93575060038710155b8015613bb55750600088888281613bac57613bac6159bb565b90506020020135115b15613bee57613be3613bc68d6111f7565b600585015460208401516001600160a01b03909116908b8b6141f7565b600385015560028401555b60208101516005840154600160a81b900463ffffffff908116911614613d0f57600060fd54602083015160405163b6ab359f60e01b81526001600160a01b03868116600483015263ffffffff909216602482015291169063b6ab359f9060440160206040518083038186803b158015613c6657600080fd5b505afa158015613c7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c9e9190615b1a565b6002811115613caf57613caf615714565b14613ceb5760405162461bcd60e51b815260206004820152600c60248201526b085393d517d153905093115160a21b60448201526064016106c9565b613d0f8c828c8c6002818110613d0357613d036159bb565b905060200201356142ff565b505050505050505050505050565b613d28848484612c21565b613d3484848484614448565b610acd5760405162461bcd60e51b81526004016106c990615b63565b600054610100900460ff16613d775760405162461bcd60e51b81526004016106c990615bb5565b613d7f61455c565b610de9614583565b600054610100900460ff16613dae5760405162461bcd60e51b81526004016106c990615bb5565b613db661455c565b610de96145ba565b600054610100900460ff16613de55760405162461bcd60e51b81526004016106c990615bb5565b613ded61455c565b613df561455c565b610ad082826145ed565b600060143610801590613e1c57506065546001600160a01b031633145b15613e2e575060131936013560601c90565b503390565b6001600160a01b03831615801590613e5357506001600160a01b03821615155b15610d1e57600081815260ff602052604081208054909190613e74906129e1565b9050806101000151613ebd5760405162461bcd60e51b8152602060048201526012602482015271214e4f545f5452414e534645525241424c4560701b60448201526064016106c9565b6006820154600160201b900463ffffffff161580613ef15750600682015463ffffffff600160201b90910481164290911610155b613f0d5760405162461bcd60e51b81526004016106c990615a30565b50600601805463ffffffff60401b19811663ffffffff909116600160401b021790556001600160a01b0391909116600090815260fe60209081526040822080546001810182559083529120015550565b600080613f8d83613784888888604051602001613724939291909283526020830191909152604082015260600190565b90506001600160a01b0387811690821614613fdc5760405162461bcd60e51b815260206004820152600f60248201526e21494e56414c49442870726f6f662960881b60448201526064016106c9565b60fd54604051630782fb5960e31b81526001600160a01b03838116600483015290911690633c17dac89060240160006040518083038186803b15801561402157600080fd5b505afa158015614035573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261405d9190810190615c00565b6020015186146140a15760405162461bcd60e51b815260206004820152600f60248201526e2150524f56494445525f4e4f4e434560881b60448201526064016106c9565b9695505050505050565b60fd546000906001600160a01b03166371ce3e66848460028181106140d2576140d26159bb565b90506020020135858560038181106140ec576140ec6159bb565b60200291909101359050614103866004818a615cc5565b6040518563ffffffff1660e01b81526004016141229493929190615d29565b60206040518083038186803b15801561413a57600080fd5b505afa15801561414e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c99190615d49565b600061417c6129d2565b60405160609190911b6bffffffffffffffffffffffff191660208201526034810185905260548101839052607481018490524360948201524260b482015260d40160408051601f198184030181529190528051602090910120949350505050565b610ad082826040518060200160405280600081525061463b565b600080808484828161420b5761420b6159bb565b9050602002013511156142d25760fd54604051632218d7d360e01b81526000916001600160a01b031690632218d7d390614251908b908b908b908b908b90600401615d66565b602060405180830381600087803b15801561426b57600080fd5b505af115801561427f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142a39190615daa565b905080156142d05780858560018181106142bf576142bf6159bb565b9050602002013592509250506142d9565b505b5060009050805b9550959350505050565b60008060006142f2858561466e565b91509150613825816146de565b600083815260ff60205260408120805490919061431b906129e1565b905060016005830154600160a01b900460ff16600681111561433f5761433f615714565b14156143ba57606080850151908201516006840154614364919063ffffffff16615dc3565b61436e9190615a7f565b60068301805463ffffffff191663ffffffff92831690811790915542909116106143aa5760068201805463ffffffff19164263ffffffff161790555b6143b5858585614899565b6120b9565b604081015181516143d19163ffffffff1690615de8565b604085015185516143e89163ffffffff1690615de8565b14156143f9576143b5858585614899565b604081015181516144109163ffffffff1690615de8565b604085015185516144279163ffffffff1690615de8565b1115614439576143b5858286866149c1565b6120b985856020015185614bd9565b60006001600160a01b0384163b1561455157836001600160a01b031663150b7a026144716129d2565b8786866040518563ffffffff1660e01b81526004016144939493929190615e0a565b602060405180830381600087803b1580156144ad57600080fd5b505af19250505080156144dd575060408051601f3d908101601f191682019092526144da91810190615e3d565b60015b614537573d80801561450b576040519150601f19603f3d011682016040523d82523d6000602084013e614510565b606091505b50805161452f5760405162461bcd60e51b81526004016106c990615b63565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612c19565b506001949350505050565b600054610100900460ff16610de95760405162461bcd60e51b81526004016106c990615bb5565b600054610100900460ff166145aa5760405162461bcd60e51b81526004016106c990615bb5565b610de96145b56129d2565b61360e565b600054610100900460ff166145e15760405162461bcd60e51b81526004016106c990615bb5565b60ca805460ff19169055565b600054610100900460ff166146145760405162461bcd60e51b81526004016106c990615bb5565b8151614627906066906020850190614f60565b508051610d1e906067906020840190614f60565b6146458383614c72565b6146526000848484614448565b610d1e5760405162461bcd60e51b81526004016106c990615b63565b6000808251604114156146a55760208301516040840151606085015160001a61469987828585614dc0565b945094505050506146d7565b8251604014156146cf57602083015160408401516146c4868383614ead565b9350935050506146d7565b506000905060025b9250929050565b60008160048111156146f2576146f2615714565b14156146fb5750565b600181600481111561470f5761470f615714565b141561475d5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016106c9565b600281600481111561477157614771615714565b14156147bf5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016106c9565b60038160048111156147d3576147d3615714565b141561482c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016106c9565b600481600481111561484057614840615714565b14156126535760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016106c9565b600083815260ff60205260409020600581015484906001600160a01b03166148c0826111f7565b6004840154600585015460208089015160028801546040805195865263ffffffff600160a81b90950485169386019390935292169083015260608201526001600160a01b0391909116907fe17e61be0a4aac2f0b6fece72cedc2ab9ca554634d5af864a9282095206a0c2b9060800160405180910390a460a083015161ffff1615614990578260a0015161ffff16836040015161495d9190615a53565b61496d9063ffffffff1642615917565b8160060160046101000a81548163ffffffff021916908363ffffffff1602179055505b60209092015160058301805463ffffffff909216600160a81b0263ffffffff60a81b19909216919091179055905550565b600084815260ff602052604090206149da858484614899565b83511580156149e95750825115155b15614aa95760068101805463ffffffff19164263ffffffff1617905560fc5460405163d71bb37b60e01b8152600481018790526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b158015614a4b57600080fd5b505af1158015614a5f573d6000803e3d6000fd5b5060029250614a6c915050565b6005820154600160a01b900460ff166006811115614a8c57614a8c615714565b146143b55760405162461bcd60e51b81526004016106c990615b3b565b6006810154600090614ac290429063ffffffff16615dc3565b63ffffffff16856040015163ffffffff168660000151614ae29190615de8565b60408601518651614af99163ffffffff1690615de8565b614b039190615aa7565b614b0d9190615e5a565b60fc549091506001600160a01b031663c54c58c4614b2a886111f7565b600585015460405160e084901b6001600160e01b03191681526001600160a01b039283166004820152911660248201526044810189905260648101849052608401602060405180830381600087803b158015614b8557600080fd5b505af1158015614b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614bbd9190615d49565b6111af5760405162461bcd60e51b81526004016106c990615b3b565b600083815260ff60209081526040808320610100909252909120829055600581015484906001600160a01b0316614c0f826111f7565b600484015460058501546040805192835263ffffffff600160a81b90920482166020840152908816908201526001600160a01b0391909116907f3d051466fe86e1bd842d67e98121d69a930caccf48fc2ae2c83119b5a7b71af690606001611076565b6001600160a01b038216614cc85760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106c9565b6000818152606860205260409020546001600160a01b031615614d2d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106c9565b614d3960008383613e33565b6001600160a01b0382166000908152606960205260408120805460019290614d62908490615917565b909155505060008181526068602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115614df75750600090506003614ea4565b8460ff16601b14158015614e0f57508460ff16601c14155b15614e205750600090506004614ea4565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614e74573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614e9d57600060019250925050614ea4565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01614ece87828885614dc0565b935093505050935093915050565b828054614ee89061592f565b90600052602060002090601f016020900481019282614f0a5760008555614f50565b82601f10614f235782800160ff19823516178555614f50565b82800160010185558215614f50579182015b82811115614f50578235825591602001919060010190614f35565b50614f5c929150614fd4565b5090565b828054614f6c9061592f565b90600052602060002090601f016020900481019282614f8e5760008555614f50565b82601f10614fa757805160ff1916838001178555614f50565b82800160010185558215614f50579182015b82811115614f50578251825591602001919060010190614fb9565b5b80821115614f5c5760008155600101614fd5565b6001600160e01b03198116811461265357600080fd5b60006020828403121561501157600080fd5b81356113c981614fe9565b60006020828403121561502e57600080fd5b5035919050565b60005b83811015615050578181015183820152602001615038565b83811115610acd5750506000910152565b60008151808452615079816020860160208601615035565b601f01601f19169290920160200192915050565b6020815260006113c96020830184615061565b6001600160a01b038116811461265357600080fd5b600080604083850312156150c857600080fd5b82356150d3816150a0565b946020939093013593505050565b6000806000606084860312156150f657600080fd5b8335615101816150a0565b92506020840135615111816150a0565b929592945050506040919091013590565b60006020828403121561513457600080fd5b81356113c9816150a0565b60008083601f84011261515157600080fd5b50813567ffffffffffffffff81111561516957600080fd5b6020830191508360208285010111156146d757600080fd5b60008060006040848603121561519657600080fd5b83359250602084013567ffffffffffffffff8111156151b457600080fd5b6151c08682870161513f565b9497909650939450505050565b60008083601f8401126151df57600080fd5b50813567ffffffffffffffff8111156151f757600080fd5b6020830191508360208260051b85010111156146d757600080fd5b803563ffffffff8116811461522657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156152645761526461522b565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156152935761529361522b565b604052919050565b600067ffffffffffffffff8211156152b5576152b561522b565b50601f01601f191660200190565b600082601f8301126152d457600080fd5b81356152e76152e28261529b565b61526a565b8181528460208386010111156152fc57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600080600060c08a8c03121561533757600080fd5b8935985060208a013567ffffffffffffffff8082111561535657600080fd5b6153628d838e016151cd565b909a50985060408c013591508082111561537b57600080fd5b6153878d838e016151cd565b909850965086915061539b60608d01615212565b955060808c01359150808211156153b157600080fd5b6153bd8d838e016152c3565b945060a08c01359150808211156153d357600080fd5b506153e08c828d0161513f565b915080935050809150509295985092959850929598565b801515811461265357600080fd5b60008060006060848603121561541a57600080fd5b8335615425816150a0565b92506020840135615435816153f7565b915061544360408501615212565b90509250925092565b6000806040838503121561545f57600080fd5b8235915060208301356007811061547557600080fd5b809150509250929050565b60008060008060008060008060008060006101008c8e0312156154a257600080fd5b8b359a5067ffffffffffffffff8060208e013511156154c057600080fd5b6154d08e60208f01358f016151cd565b909b50995060408d01358110156154e657600080fd5b6154f68e60408f01358f016151cd565b909950975060608d0135965061550e60808e01615212565b95508060a08e0135111561552157600080fd5b6155318e60a08f01358f016152c3565b94508060c08e0135111561554457600080fd5b6155548e60c08f01358f016152c3565b93508060e08e0135111561556757600080fd5b506155788d60e08e01358e0161513f565b81935080925050509295989b509295989b9093969950565b600080604083850312156155a357600080fd5b823591506155b360208401615212565b90509250929050565b600080604083850312156155cf57600080fd5b82356155da816150a0565b91506020830135615475816153f7565b600080600080600080600080600060c08a8c03121561560857600080fd5b8935985060208a0135975060408a013567ffffffffffffffff8082111561562e57600080fd5b61563a8d838e016151cd565b909950975060608c013591508082111561565357600080fd5b61565f8d838e016151cd565b909750955060808c01359150808211156153b157600080fd5b6000806000806080858703121561568e57600080fd5b8435615699816150a0565b935060208501356156a9816150a0565b925060408501359150606085013567ffffffffffffffff8111156156cc57600080fd5b6156d8878288016152c3565b91505092959194509250565b6000806000606084860312156156f957600080fd5b8335615704816150a0565b92506020840135615435816150a0565b634e487b7160e01b600052602160045260246000fd5b6007811061574857634e487b7160e01b600052602160045260246000fd5b9052565b60408152825160408201526020830151606082015260408301516080820152606083015160a0820152608083015160c0820152600060a084015161579b60e08401826001600160a01b03169052565b5060c08401516101006157b08185018361572a565b60e086015191506101206157cb8186018463ffffffff169052565b908601519150610140906157e68583018463ffffffff169052565b86015191506101606157ff8582018463ffffffff169052565b9086015191506101809061581a8583018463ffffffff169052565b86015191506101a06158338582018463ffffffff169052565b8187015192506101c091508182860152615851610200860184615061565b90870151858203603f19016101e087015290925090506158718282615061565b925050506113c960208301846001600160a01b03169052565b6000806040838503121561589d57600080fd5b82356158a8816150a0565b91506020830135615475816150a0565b60208082526005908201526404282aaa8960db1b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000821982111561592a5761592a615901565b500190565b600181811c9082168061594357607f821691505b6020821081141561596457634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526010908201526f21494e56414c4944287374617475732960801b604082015260600190565b602080825260099082015268214d494e5f5445524d60b81b604082015260600190565b600063ffffffff80831681851681830481118215151615615a7657615a76615901565b02949350505050565b600063ffffffff808316818516808303821115615a9e57615a9e615901565b01949350505050565b600082821015615ab957615ab9615901565b500390565b66697066733a2f2f60c81b815260008251615ae0816007850160208701615035565b9190910160070192915050565b60208082526013908201527221494e56414c494428706c616e50726f6f662960681b604082015260600190565b600060208284031215615b2c57600080fd5b8151600381106113c957600080fd5b6020808252600e908201526d21554e50524f4345535341424c4560901b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020808385031215615c1357600080fd5b825167ffffffffffffffff80821115615c2b57600080fd5b9084019060608287031215615c3f57600080fd5b615c47615241565b8251615c52816150a0565b81528284015184820152604083015182811115615c6e57600080fd5b80840193505086601f840112615c8357600080fd5b82519150615c936152e28361529b565b8281528785848601011115615ca757600080fd5b615cb683868301878701615035565b60408201529695505050505050565b60008085851115615cd557600080fd5b83861115615ce257600080fd5b5050600583901b0193919092039150565b81835260006001600160fb1b03831115615d0c57600080fd5b8260051b8083602087013760009401602001938452509192915050565b8481528360208201526060604082015260006140a1606083018486615cf3565b600060208284031215615d5b57600080fd5b81516113c9816153f7565b6001600160a01b0386811682528516602082015263ffffffff84166040820152608060608201819052600090615d9f9083018486615cf3565b979650505050505050565b600060208284031215615dbc57600080fd5b5051919050565b600063ffffffff83811690831681811015615de057615de0615901565b039392505050565b600082615e0557634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906140a190830184615061565b600060208284031215615e4f57600080fd5b81516113c981614fe9565b6000816000190483118215151615615e7457615e74615901565b50029056fea2646970667358221220e4825e7b2c0443ab47bd26821b65a1aafb63d45486ee62c01414736184e97fef64736f6c63430008090033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061025e5760003560e01c80637df7b2aa11610146578063b88d4fde116100c3578063d0ebdbe711610087578063d0ebdbe714610557578063d67dc0de1461056a578063da742228146105b3578063dc311dd3146105c6578063e985e9c5146105e7578063f2fde38b1461062357600080fd5b8063b88d4fde146104ea578063bf158fd2146104fd578063c4d66de814610510578063c86e695414610523578063c87b56dd1461054457600080fd5b80638fe17b161161010a5780638fe17b1614610496578063925fa591146104a957806395d89b41146104bc578063a22cb465146104c4578063ac58e37b146104d757600080fd5b80637df7b2aa14610444578063825527ff146104575780638456cb591461046a578063876bebbb146104725780638da5cb5b1461048557600080fd5b806342842e0e116101df5780635c975abb116101a35780635c975abb146103e75780636352211e146103f257806370a0823114610405578063715018a61461041857806374c14439146104205780637da0a8771461043357600080fd5b806342842e0e1461036b57806345041a461461037e578063486ff0cd146103915780634d5106ae146103b2578063572b6c05146103c557600080fd5b806323b872dd1161022657806323b872dd146102f3578063291b9a3f1461030657806336fd3a8a1461033d5780633f4ba83a1461035057806341f23f0a1461035857600080fd5b806301ffc9a714610263578063023a584e1461028b57806306fdde03146102a0578063081812fc146102b5578063095ea7b3146102e0575b600080fd5b610276610271366004614fff565b610636565b60405190151581526020015b60405180910390f35b61029e61029936600461501c565b610688565b005b6102a8610ad4565b604051610282919061508d565b6102c86102c336600461501c565b610b66565b6040516001600160a01b039091168152602001610282565b61029e6102ee3660046150b5565b610bfb565b61029e6103013660046150e1565b610d23565b61032f610314366004615122565b6001600160a01b0316600090815260fe602052604090205490565b604051908152602001610282565b61032f61034b3660046150b5565b610d5b565b61029e610d98565b61029e61036636600461501c565b610deb565b61029e6103793660046150e1565b611084565b61029e61038c366004615181565b61109f565b6040805180820190915260058152640322e322e360dc1b60208201526102a8565b61029e6103c0366004615319565b6111b7565b6102766103d3366004615122565b6065546001600160a01b0391821691161490565b60ca5460ff16610276565b6102c861040036600461501c565b6111f7565b61032f610413366004615122565b61126e565b61029e6112f5565b61032f61042e366004615405565b611348565b6065546001600160a01b03166102c8565b61029e61045236600461544c565b6113d0565b61029e610465366004615480565b611c29565b61029e611c8d565b61032f6104803660046150b5565b611cde565b6098546001600160a01b03166102c8565b60fd546102c8906001600160a01b031681565b61029e6104b7366004615590565b611d09565b6102a86120c0565b61029e6104d23660046155bc565b6120cf565b61029e6104e53660046155ea565b6120e1565b61029e6104f8366004615678565b612156565b60fc546102c8906001600160a01b031681565b61029e61051e366004615122565b61218f565b61032f61053136600461501c565b6000908152610100602052604090205490565b6102a861055236600461501c565b6122c7565b61029e610565366004615122565b612581565b61032f6105783660046156e4565b6001600160a01b0392831660009081526101046020908152604080832094909516825292835283812063ffffffff9290921681529152205490565b61029e6105c1366004615122565b6125ec565b6105d96105d436600461501c565b612656565b60405161028292919061574c565b6102766105f536600461588a565b6001600160a01b039182166000908152606b6020908152604080832093909416825291909152205460ff1690565b61029e610631366004615122565b612915565b60006001600160e01b031982166380ac58cd60e01b148061066757506001600160e01b03198216635b5e139f60e01b145b8061068257506301ffc9a760e01b6001600160e01b03198316145b92915050565b80610692816111f7565b6001600160a01b03166106a36129d2565b6001600160a01b0316146106d25760405162461bcd60e51b81526004016106c9906158b8565b60405180910390fd5b60ca5460ff16156106f55760405162461bcd60e51b81526004016106c9906158d7565b600082815260ff6020526040902060036005820154600160a01b900460ff16600681111561072557610725615714565b1480610750575060066005820154600160a01b900460ff16600681111561074e5761074e615714565b145b61078a5760405162461bcd60e51b815260206004820152600b60248201526a085393d517d4105554d15160aa1b60448201526064016106c9565b600581015483906001600160a01b03166107a3826111f7565b6004840154600585015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f7ee0fc3eab7021686f891346ebbf5bab192d6f9995fcc66021f4551888dc1481910160405180910390a460066005820154600160a01b900460ff16600681111561082157610821615714565b141561083f57600501805460ff60a01b1916600160a11b1790555050565b600061084e82600001546129e1565b9050806080015163ffffffff16600014806108a15750608081015160058301546001600160a01b03166000908152610103602090815260408083208286015163ffffffff90811685529252909120549116115b6108db5760405162461bcd60e51b815260206004820152600b60248201526a214d41585f41435449564560a81b60448201526064016106c9565b600582018054600160a11b60ff60a01b198216179091556001600160a01b031660009081526101026020526040812080546001929061091b908490615917565b909155505060058201546001600160a01b038116600090815261010360209081526040808320600160a81b90940463ffffffff168352929052908120805460019290610968908490615917565b9091555060019050610104600061097e876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff1681529252812080549091906109d1908490615917565b9091555050600682015463ffffffff42811691161015610a035760068201805463ffffffff19164263ffffffff161790555b60fc5460405163d71bb37b60e01b8152600481018690526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b158015610a4957600080fd5b505af1158015610a5d573d6000803e3d6000fd5b5060029250610a6a915050565b6005830154600160a01b900460ff166006811115610a8a57610a8a615714565b14610acd5760405162461bcd60e51b815260206004820152601360248201527221494e53554646494349454e545f46554e445360681b60448201526064016106c9565b50505b5050565b606060668054610ae39061592f565b80601f0160208091040260200160405190810160405280929190818152602001828054610b0f9061592f565b8015610b5c5780601f10610b3157610100808354040283529160200191610b5c565b820191906000526020600020905b815481529060010190602001808311610b3f57829003601f168201915b5050505050905090565b6000818152606860205260408120546001600160a01b0316610bdf5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106c9565b506000908152606a60205260409020546001600160a01b031690565b6000610c06826111f7565b9050806001600160a01b0316836001600160a01b03161415610c745760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106c9565b806001600160a01b0316610c866129d2565b6001600160a01b03161480610ca25750610ca2816105f56129d2565b610d145760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106c9565b610d1e8383612abc565b505050565b610d34610d2e6129d2565b82612b2a565b610d505760405162461bcd60e51b81526004016106c99061596a565b610d1e838383612c21565b6001600160a01b038216600090815260fe60205260408120805483908110610d8557610d856159bb565b9060005260206000200154905092915050565b610da06129d2565b6001600160a01b0316610dbb6098546001600160a01b031690565b6001600160a01b031614610de15760405162461bcd60e51b81526004016106c9906159d1565b610de9612dcc565b565b80610df5816111f7565b6001600160a01b0316610e066129d2565b6001600160a01b03161480610e445750600081815260ff60205260409020600501546001600160a01b0316610e396129d2565b6001600160a01b0316145b610e605760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff1615610e835760405162461bcd60e51b81526004016106c9906158d7565b600082815260ff6020526040902060036005820154600160a01b900460ff166006811115610eb357610eb3615714565b14158015610ee05750600580820154600160a01b900460ff166006811115610edd57610edd615714565b14155b8015610f0c575060046005820154600160a01b900460ff166006811115610f0957610f09615714565b14155b8015610f38575060016005820154600160a01b900460ff166006811115610f3557610f35615714565b14155b610f545760405162461bcd60e51b81526004016106c990615a06565b6006810154600160201b900463ffffffff161580610f885750600681015463ffffffff600160201b90910481164290911610155b610fa45760405162461bcd60e51b81526004016106c990615a30565b6000610fb382600001546129e1565b90508060e00151610ff65760405162461bcd60e51b815260206004820152600d60248201526c214e4f545f5041555341424c4560981b60448201526064016106c9565b600582018054600360a11b60ff60a01b1982161790915584906001600160a01b0316611021826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f3b1ababbfb41865093a096e886e08d3058f1adbce6c29e7be7ed6fd16b70802891015b60405180910390a450505050565b610d1e83838360405180602001604052806000815250612156565b826110a9816111f7565b6001600160a01b03166110ba6129d2565b6001600160a01b031614806110f85750600081815260ff60205260409020600501546001600160a01b03166110ed6129d2565b6001600160a01b0316145b6111145760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff16156111375760405162461bcd60e51b81526004016106c9906158d7565b600084815260ff6020526040902060046005820154600160a01b900460ff16600681111561116757611167615714565b14156111a15760405162461bcd60e51b81526020600482015260096024820152680850d05390d153115160ba1b60448201526064016106c9565b6111af600882018585614edc565b505050505050565b60ca5460ff16156111da5760405162461bcd60e51b81526004016106c9906158d7565b6111eb898989898989898989612e65565b50505050505050505050565b6000818152606860205260408120546001600160a01b0316806106825760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106c9565b60006001600160a01b0382166112d95760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106c9565b506001600160a01b031660009081526069602052604090205490565b6112fd6129d2565b6001600160a01b03166113186098546001600160a01b031690565b6001600160a01b03161461133e5760405162461bcd60e51b81526004016106c9906159d1565b610de9600061360e565b6000821561137057506001600160a01b038316600090815261010160205260409020546113c9565b63ffffffff8216156113ad57506001600160a01b03831660009081526101036020908152604080832063ffffffff851684529091529020546113c9565b506001600160a01b038316600090815261010260205260409020545b9392505050565b60fc546001600160a01b03166113e46129d2565b6001600160a01b03161461140a5760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff161561142d5760405162461bcd60e51b81526004016106c9906158d7565b600082815260ff6020526040902042600183600681111561145057611450615714565b14156115e95760008481526101006020526040902054806114b35760405162461bcd60e51b815260206004820152601960248201527f21494e56414c49442870656e64696e67506c616e44617461290000000000000060448201526064016106c9565b60006114be826129e1565b600585015490915086906001600160a01b03166114da826111f7565b6004870154600588015460208087015160028b01546040805195865263ffffffff600160a81b90950485169386019390935292169083015260608201526001600160a01b0391909116907fe17e61be0a4aac2f0b6fece72cedc2ab9ca554634d5af864a9282095206a0c2b9060800160405180910390a4602081015160058501805463ffffffff909216600160a81b0263ffffffff60a81b1990921691909117905581845560a081015161ffff16156115d2578060a0015161ffff1681604001516115a59190615a53565b6115af9084615a7f565b8460060160046101000a81548163ffffffff021916908363ffffffff1602179055505b505060008481526101006020526040812055610acd565b60028360068111156115fd576115fd615714565b14156117db57600582018054600160a21b60ff60a01b198216179091556001600160a01b0316600090815261010260205260408120805460019290611643908490615aa7565b909155505060058201546001600160a01b038116600090815261010360209081526040808320600160a81b90940463ffffffff168352929052908120805460019290611690908490615aa7565b9091555060009050610104816116a5876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff1681529252902054111561175857600161010460006116ff876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff168152925281208054909190611752908490615aa7565b90915550505b600582015484906001600160a01b0316611771826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f58e4414596fd750dbb9dabfe65b97bf5add2061f5902f34e2b82a9c25bd79f98910160405180910390a46117d684613660565b610acd565b60068360068111156117ef576117ef615714565b14156119c557600582018054600360a01b60ff60a01b198216179091556001600160a01b0316600090815261010260205260408120805460019290611835908490615aa7565b909155505060058201546001600160a01b038116600090815261010360209081526040808320600160a81b90940463ffffffff168352929052908120805460019290611882908490615aa7565b909155506000905061010481611897876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff1681529252902054111561194a57600161010460006118f1876111f7565b6001600160a01b03908116825260208083019390935260409182016000908120600588015492831682528452828120600160a81b90920463ffffffff168152925281208054909190611944908490615aa7565b90915550505b600582015484906001600160a01b0316611963826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f7afd3b59e582bb56b590409b808e910ae787056cb10b682b9bdefa44c8eb940d91015b60405180910390a4610acd565b60038360068111156119d9576119d9615714565b1415611a6357600582018054600560a01b60ff60a01b1982161790915584906001600160a01b0316611a0a826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917f44abb4f4529fdbcacc1ee98eef9318eaf9a12044d6925a2dc2c702959d9352f191016119b8565b6004836006811115611a7757611a77615714565b1415611bfb576000611a8c83600001546129e1565b905060016005840154600160a01b900460ff166006811115611ab057611ab0615714565b1415611b2c57600583015485906001600160a01b0316611acf826111f7565b6004860154600587015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917ff42e506093cb49dad3d3349cf7a2b390140be665daecb2c820e903afd12b1df7910160405180910390a45b60408101516006840154611b46919063ffffffff16615a7f565b60068401805463ffffffff191663ffffffff9283169081179091559083161015611b805760058301805460ff60a01b1916600160a11b1790555b600583015485906001600160a01b0316611b99826111f7565b6004860154600587015460408051928352600160a81b90910463ffffffff1660208301526001600160a01b0392909216917fcdd2eee203a384f2c6e81f39021f7e3ebef3a21ccd0d0f6dd117387ab61b6b54910160405180910390a450610acd565b6005836006811115611c0f57611c0f615714565b1415610acd57600060028301819055600383015550505050565b60ca5460ff1615611c4c5760405162461bcd60e51b81526004016106c9906158d7565b6000611c5f8c8c8c8c8c8b8b8a8a612e65565b9050611c6b8785613707565b50600090815260ff602052604090206001019590955550505050505050505050565b611c956129d2565b6001600160a01b0316611cb06098546001600160a01b031690565b6001600160a01b031614611cd65760405162461bcd60e51b81526004016106c9906159d1565b610de961382d565b6001600160a01b038216600090815261010160205260408120805483908110610d8557610d856159bb565b81611d13816111f7565b6001600160a01b0316611d246129d2565b6001600160a01b03161480611d625750600081815260ff60205260409020600501546001600160a01b0316611d576129d2565b6001600160a01b0316145b611d7e5760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff1615611da15760405162461bcd60e51b81526004016106c9906158d7565b600083815260ff6020526040902060046005820154600160a01b900460ff166006811115611dd157611dd1615714565b1415611def5760405162461bcd60e51b81526004016106c990615a06565b4263ffffffff8416611edd57611e04856111f7565b6001600160a01b0316611e156129d2565b6001600160a01b031614611e3b5760405162461bcd60e51b81526004016106c9906158b8565b60068201805463ffffffff60401b1916600160401b63ffffffff871602179055600582015485906001600160a01b0316611e74826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff9081166020840152891682820152516001600160a01b0392909216917fc54424be96a88104b924830a25713de0140a7b7048d7a26370e735b421b057869181900360600190a46120b9565b8063ffffffff168463ffffffff1611611fcc576006820154600160201b900463ffffffff161580611f235750600682015463ffffffff600160201b909104811690821610155b611f3f5760405162461bcd60e51b81526004016106c990615a30565b600682018054600160401b63ffffffff84169081026bffffffff00000000ffffffff199092161717905560fc5460405163d71bb37b60e01b8152600481018790526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b158015611faf57600080fd5b505af1158015611fc3573d6000803e3d6000fd5b505050506120b9565b6006820154600160201b900463ffffffff161580611fff5750600682015463ffffffff600160201b909104811690851610155b61201b5760405162461bcd60e51b81526004016106c990615a30565b60068201805463ffffffff60401b1916600160401b63ffffffff871602179055600582015485906001600160a01b0316612054826111f7565b6004850154600586015460408051928352600160a81b90910463ffffffff9081166020840152891682820152516001600160a01b0392909216917fc54424be96a88104b924830a25713de0140a7b7048d7a26370e735b421b057869181900360600190a45b5050505050565b606060678054610ae39061592f565b610ad06120da6129d2565b8383613886565b886120eb816111f7565b6001600160a01b03166120fc6129d2565b6001600160a01b0316146121225760405162461bcd60e51b81526004016106c9906158b8565b60ca5460ff16156121455760405162461bcd60e51b81526004016106c9906158d7565b6111eb8a8a8a8a8a8a8a8a8a613955565b6121676121616129d2565b83612b2a565b6121835760405162461bcd60e51b81526004016106c99061596a565b610acd84848484613d1d565b600054610100900460ff166121aa5760005460ff16156121ae565b303b155b6122115760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106c9565b600054610100900460ff16158015612233576000805461ffff19166101011790555b61223b613d50565b612243613d87565b612297604051806040016040528060128152602001714361736b20537562736372697074696f6e7360701b815250604051806040016040528060088152602001674341534b5355425360c01b815250613dbe565b60fd80546001600160a01b0319166001600160a01b0384161790558015610ad0576000805461ff00191690555050565b6000818152606860205260409020546060906001600160a01b03166123465760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106c9565b600082815260ff6020818152604080842081516101c08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004810154608083015260058101546001600160a01b03811660a08401529192909160c0840191600160a01b9091041660068111156123c7576123c7615714565b60068111156123d8576123d8615714565b8152600582015463ffffffff600160a81b820481166020840152600160c81b9091048116604083015260068301548082166060840152600160201b810482166080840152600160401b90041660a082015260078201805460c09092019161243e9061592f565b80601f016020809104026020016040519081016040528092919081815260200182805461246a9061592f565b80156124b75780601f1061248c576101008083540402835291602001916124b7565b820191906000526020600020905b81548152906001019060200180831161249a57829003601f168201915b505050505081526020016008820180546124d09061592f565b80601f01602080910402602001604051908101604052809291908181526020018280546124fc9061592f565b80156125495780601f1061251e57610100808354040283529160200191612549565b820191906000526020600020905b81548152906001019060200180831161252c57829003601f168201915b505050505081525050905080610180015160405160200161256a9190615abe565b604051602081830303815290604052915050919050565b6125896129d2565b6001600160a01b03166125a46098546001600160a01b031690565b6001600160a01b0316146125ca5760405162461bcd60e51b81526004016106c9906159d1565b60fc80546001600160a01b0319166001600160a01b0392909216919091179055565b6125f46129d2565b6001600160a01b031661260f6098546001600160a01b031690565b6001600160a01b0316146126355760405162461bcd60e51b81526004016106c9906159d1565b606580546001600160a01b0319166001600160a01b03831617905550565b50565b604080516101c08101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e0820183905261010082018390526101208201839052610140820183905261016082019290925261018081018290526101a0810191909152600082815260ff6020818152604080842081516101c08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004810154608083015260058101546001600160a01b03811660a08401529192909160c0840191600160a01b90910416600681111561274a5761274a615714565b600681111561275b5761275b615714565b8152600582015463ffffffff600160a81b820481166020840152600160c81b9091048116604083015260068301548082166060840152600160201b810482166080840152600160401b90041660a082015260078201805460c0909201916127c19061592f565b80601f01602080910402602001604051908101604052809291908181526020018280546127ed9061592f565b801561283a5780601f1061280f5761010080835404028352916020019161283a565b820191906000526020600020905b81548152906001019060200180831161281d57829003601f168201915b505050505081526020016008820180546128539061592f565b80601f016020809104026020016040519081016040528092919081815260200182805461287f9061592f565b80156128cc5780601f106128a1576101008083540402835291602001916128cc565b820191906000526020600020905b8154815290600101906020018083116128af57829003601f168201915b50505050508152505091506128f8836000908152606860205260409020546001600160a01b0316151590565b1561290d57612906836111f7565b9050915091565b506000915091565b61291d6129d2565b6001600160a01b03166129386098546001600160a01b031690565b6001600160a01b03161461295e5760405162461bcd60e51b81526004016106c9906159d1565b6001600160a01b0381166129c35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106c9565b6126538161360e565b3b151590565b60006129dc613dff565b905090565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915250604080516101208101825260a083811c8252608084811c63ffffffff908116602080860191909152606087811c8316868801529587901c8216958501959095529385901c90931692820192909252601083901c61ffff1691810191909152600882901c60ff1660c082015260f89190911b600160f81b8181161460e0830152600160f91b9081161461010082015290565b6000818152606a6020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612af1826111f7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152606860205260408120546001600160a01b0316612ba35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106c9565b6000612bae836111f7565b9050806001600160a01b0316846001600160a01b03161480612be95750836001600160a01b0316612bde84610b66565b6001600160a01b0316145b80612c1957506001600160a01b038082166000908152606b602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316612c34826111f7565b6001600160a01b031614612c9c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106c9565b6001600160a01b038216612cfe5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106c9565b612d09838383613e33565b612d14600082612abc565b6001600160a01b0383166000908152606960205260408120805460019290612d3d908490615aa7565b90915550506001600160a01b0382166000908152606960205260408120805460019290612d6b908490615917565b909155505060008181526068602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60ca5460ff16612e155760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106c9565b60ca805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612e486129d2565b6040516001600160a01b03909116815260200160405180910390a1565b60006004881015612eb15760405162461bcd60e51b815260206004820152601660248201527521494e56414c494428706c616e50726f6f664c656e2960501b60448201526064016106c9565b600060038710612f1a57612f138a8a6000818110612ed157612ed16159bb565b905060200201358c8c8c6003818110612eec57612eec6159bb565b905060200201358b8b6002818110612f0657612f066159bb565b9050602002013589613f5d565b9050612f5f565b612f5c8a8a6000818110612f3057612f306159bb565b905060200201358c8c8c6003818110612f4b57612f4b6159bb565b905060200201356000801b89613f5d565b90505b612f698a8a6140ab565b612f855760405162461bcd60e51b81526004016106c990615aed565b6000612fa98b8b6002818110612f9d57612f9d6159bb565b905060200201356129e1565b905060006130038c8c6000818110612fc357612fc36159bb565b905060200201358d8d6001818110612fdd57612fdd6159bb565b905060200201358e8e6002818110612ff757612ff76159bb565b90506020020135614172565b9050816080015163ffffffff1660001480613052575060808201516001600160a01b0384166000908152610103602090815260408083208287015163ffffffff90811685529252909120549116115b61308c5760405162461bcd60e51b815260206004820152600b60248201526a214d41585f41435449564560a81b60448201526064016106c9565b600060fd54602084015160405163b6ab359f60e01b81526001600160a01b03878116600483015263ffffffff909216602482015291169063b6ab359f9060440160206040518083038186803b1580156130e457600080fd5b505afa1580156130f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061311c9190615b1a565b600281111561312d5761312d615714565b146131695760405162461bcd60e51b815260206004820152600c60248201526b085393d517d153905093115160a21b60448201526064016106c9565b61317a6131746129d2565b826141dd565b600081815260ff602090815260409091206005810180549285015163ffffffff16600160a81b02600164ffffffff0160a01b03199093166001600160a01b0387161792909217909155428d8d60018181106131d7576131d76159bb565b60200291909101356004840155508d8d60028181106131f8576131f86159bb565b602002919091013583555060068201805463ffffffff60401b1916600160401b63ffffffff8d1602179055613231600783018989614edc565b5060058201805463ffffffff60c81b1916600160c81b63ffffffff84160217905560a084015161ffff16156132a5578360a0015161ffff1684604001516132789190615a53565b6132829082615a7f565b8260060160046101000a81548163ffffffff021916908363ffffffff1602179055505b83516132d45760058201805460ff60a01b1916600160a11b17905560068201805463ffffffff19169055613356565b606084015163ffffffff16156133295760058201805460ff60a01b1916600160a01b17905560608401516133089082615a7f565b60068301805463ffffffff191663ffffffff92909216919091179055613356565b60058201805460ff60a01b1916600160a11b17905560068201805463ffffffff191663ffffffff83161790555b60fe60006133626129d2565b6001600160a01b03908116825260208083019390935260409182016000908120805460018181018355918352858320018890559189168082526101018552838220805480850182559083528583200188905581526101029093529082208054919290916133d0908490615917565b90915550506001600160a01b0385166000908152610103602090815260408083208783015163ffffffff1684529091528120805460019290613413908490615917565b909155506001905061010460006134286129d2565b6001600160a01b03908116825260208083019390935260409182016000908120918a1681529083528181208884015163ffffffff16825290925281208054909190613474908490615917565b909155506134a39050613486846111f7565b600584015460208701516001600160a01b03909116908f8f6141f7565b6003840155600283015560fc5460405163d71bb37b60e01b8152600481018590526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b1580156134f357600080fd5b505af1158015613507573d6000803e3d6000fd5b5060029250613514915050565b6005830154600160a01b900460ff16600681111561353457613534615714565b148061355f575060016005830154600160a01b900460ff16600681111561355d5761355d615714565b145b61357b5760405162461bcd60e51b81526004016106c990615b3b565b600582015483906001600160a01b0316613594826111f7565b60048501546005860154600287015460408051938452600160a81b90920463ffffffff166020840152908201526001600160a01b0391909116907f9fb45eab820cdd481e286e8c699e1c01031bb833c58f7cfba3ca8d1db6d98d819060600160405180910390a450909d9c50505050505050505050505050565b609880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061366b826111f7565b905061367981600084613e33565b613684600083612abc565b6001600160a01b03811660009081526069602052604081208054600192906136ad908490615aa7565b909155505060008281526068602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60008061378a836137848660405160200161372491815260200190565b60408051601f1981840301815282825280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000084830152603c8085019190915282518085039091018152605c909301909152815191012090565b906142e3565b905060006137ca8560408051808201909152600080825260208201525060408051808201909152606082901c815260509190911c61ffff16602082015290565b9050816001600160a01b031681600001516001600160a01b0316146138255760405162461bcd60e51b815260206004820152601160248201527021494e56414c4944286e6574776f726b2960781b60448201526064016106c9565b509392505050565b60ca5460ff16156138505760405162461bcd60e51b81526004016106c9906158d7565b60ca805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612e486129d2565b816001600160a01b0316836001600160a01b031614156138e85760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106c9565b6001600160a01b038381166000818152606b6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60048610156139765760405162461bcd60e51b81526004016106c990615aed565b600089815260ff60205260409020600681015463ffffffff1615806139a75750600681015463ffffffff4281169116115b6139e35760405162461bcd60e51b815260206004820152600d60248201526c085391515117d491539155d053609a1b60448201526064016106c9565b60026005820154600160a01b900460ff166006811115613a0557613a05615714565b1480613a30575060016005820154600160a01b900460ff166006811115613a2e57613a2e615714565b145b613a4c5760405162461bcd60e51b81526004016106c990615a06565b600060038610613aa857613aa189896000818110613a6c57613a6c6159bb565b905060200201358b8b8b6003818110613a8757613a876159bb565b905060200201358a8a6002818110612f0657612f066159bb565b9050613adc565b613ad989896000818110613abe57613abe6159bb565b905060200201358b8b8b6003818110612f4b57612f4b6159bb565b90505b613ae689896140ab565b613b025760405162461bcd60e51b81526004016106c990615aed565b6000613b1a8a8a6002818110612f9d57612f9d6159bb565b60058401549091506001600160a01b03838116911614613b715760405162461bcd60e51b815260206004820152601260248201527121494e56414c49442870726f76696465722960701b60448201526064016106c9565b613b7f600784018686614edc565b506002830154158015613b93575060038710155b8015613bb55750600088888281613bac57613bac6159bb565b90506020020135115b15613bee57613be3613bc68d6111f7565b600585015460208401516001600160a01b03909116908b8b6141f7565b600385015560028401555b60208101516005840154600160a81b900463ffffffff908116911614613d0f57600060fd54602083015160405163b6ab359f60e01b81526001600160a01b03868116600483015263ffffffff909216602482015291169063b6ab359f9060440160206040518083038186803b158015613c6657600080fd5b505afa158015613c7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c9e9190615b1a565b6002811115613caf57613caf615714565b14613ceb5760405162461bcd60e51b815260206004820152600c60248201526b085393d517d153905093115160a21b60448201526064016106c9565b613d0f8c828c8c6002818110613d0357613d036159bb565b905060200201356142ff565b505050505050505050505050565b613d28848484612c21565b613d3484848484614448565b610acd5760405162461bcd60e51b81526004016106c990615b63565b600054610100900460ff16613d775760405162461bcd60e51b81526004016106c990615bb5565b613d7f61455c565b610de9614583565b600054610100900460ff16613dae5760405162461bcd60e51b81526004016106c990615bb5565b613db661455c565b610de96145ba565b600054610100900460ff16613de55760405162461bcd60e51b81526004016106c990615bb5565b613ded61455c565b613df561455c565b610ad082826145ed565b600060143610801590613e1c57506065546001600160a01b031633145b15613e2e575060131936013560601c90565b503390565b6001600160a01b03831615801590613e5357506001600160a01b03821615155b15610d1e57600081815260ff602052604081208054909190613e74906129e1565b9050806101000151613ebd5760405162461bcd60e51b8152602060048201526012602482015271214e4f545f5452414e534645525241424c4560701b60448201526064016106c9565b6006820154600160201b900463ffffffff161580613ef15750600682015463ffffffff600160201b90910481164290911610155b613f0d5760405162461bcd60e51b81526004016106c990615a30565b50600601805463ffffffff60401b19811663ffffffff909116600160401b021790556001600160a01b0391909116600090815260fe60209081526040822080546001810182559083529120015550565b600080613f8d83613784888888604051602001613724939291909283526020830191909152604082015260600190565b90506001600160a01b0387811690821614613fdc5760405162461bcd60e51b815260206004820152600f60248201526e21494e56414c49442870726f6f662960881b60448201526064016106c9565b60fd54604051630782fb5960e31b81526001600160a01b03838116600483015290911690633c17dac89060240160006040518083038186803b15801561402157600080fd5b505afa158015614035573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261405d9190810190615c00565b6020015186146140a15760405162461bcd60e51b815260206004820152600f60248201526e2150524f56494445525f4e4f4e434560881b60448201526064016106c9565b9695505050505050565b60fd546000906001600160a01b03166371ce3e66848460028181106140d2576140d26159bb565b90506020020135858560038181106140ec576140ec6159bb565b60200291909101359050614103866004818a615cc5565b6040518563ffffffff1660e01b81526004016141229493929190615d29565b60206040518083038186803b15801561413a57600080fd5b505afa15801561414e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c99190615d49565b600061417c6129d2565b60405160609190911b6bffffffffffffffffffffffff191660208201526034810185905260548101839052607481018490524360948201524260b482015260d40160408051601f198184030181529190528051602090910120949350505050565b610ad082826040518060200160405280600081525061463b565b600080808484828161420b5761420b6159bb565b9050602002013511156142d25760fd54604051632218d7d360e01b81526000916001600160a01b031690632218d7d390614251908b908b908b908b908b90600401615d66565b602060405180830381600087803b15801561426b57600080fd5b505af115801561427f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142a39190615daa565b905080156142d05780858560018181106142bf576142bf6159bb565b9050602002013592509250506142d9565b505b5060009050805b9550959350505050565b60008060006142f2858561466e565b91509150613825816146de565b600083815260ff60205260408120805490919061431b906129e1565b905060016005830154600160a01b900460ff16600681111561433f5761433f615714565b14156143ba57606080850151908201516006840154614364919063ffffffff16615dc3565b61436e9190615a7f565b60068301805463ffffffff191663ffffffff92831690811790915542909116106143aa5760068201805463ffffffff19164263ffffffff161790555b6143b5858585614899565b6120b9565b604081015181516143d19163ffffffff1690615de8565b604085015185516143e89163ffffffff1690615de8565b14156143f9576143b5858585614899565b604081015181516144109163ffffffff1690615de8565b604085015185516144279163ffffffff1690615de8565b1115614439576143b5858286866149c1565b6120b985856020015185614bd9565b60006001600160a01b0384163b1561455157836001600160a01b031663150b7a026144716129d2565b8786866040518563ffffffff1660e01b81526004016144939493929190615e0a565b602060405180830381600087803b1580156144ad57600080fd5b505af19250505080156144dd575060408051601f3d908101601f191682019092526144da91810190615e3d565b60015b614537573d80801561450b576040519150601f19603f3d011682016040523d82523d6000602084013e614510565b606091505b50805161452f5760405162461bcd60e51b81526004016106c990615b63565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612c19565b506001949350505050565b600054610100900460ff16610de95760405162461bcd60e51b81526004016106c990615bb5565b600054610100900460ff166145aa5760405162461bcd60e51b81526004016106c990615bb5565b610de96145b56129d2565b61360e565b600054610100900460ff166145e15760405162461bcd60e51b81526004016106c990615bb5565b60ca805460ff19169055565b600054610100900460ff166146145760405162461bcd60e51b81526004016106c990615bb5565b8151614627906066906020850190614f60565b508051610d1e906067906020840190614f60565b6146458383614c72565b6146526000848484614448565b610d1e5760405162461bcd60e51b81526004016106c990615b63565b6000808251604114156146a55760208301516040840151606085015160001a61469987828585614dc0565b945094505050506146d7565b8251604014156146cf57602083015160408401516146c4868383614ead565b9350935050506146d7565b506000905060025b9250929050565b60008160048111156146f2576146f2615714565b14156146fb5750565b600181600481111561470f5761470f615714565b141561475d5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016106c9565b600281600481111561477157614771615714565b14156147bf5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016106c9565b60038160048111156147d3576147d3615714565b141561482c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016106c9565b600481600481111561484057614840615714565b14156126535760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016106c9565b600083815260ff60205260409020600581015484906001600160a01b03166148c0826111f7565b6004840154600585015460208089015160028801546040805195865263ffffffff600160a81b90950485169386019390935292169083015260608201526001600160a01b0391909116907fe17e61be0a4aac2f0b6fece72cedc2ab9ca554634d5af864a9282095206a0c2b9060800160405180910390a460a083015161ffff1615614990578260a0015161ffff16836040015161495d9190615a53565b61496d9063ffffffff1642615917565b8160060160046101000a81548163ffffffff021916908363ffffffff1602179055505b60209092015160058301805463ffffffff909216600160a81b0263ffffffff60a81b19909216919091179055905550565b600084815260ff602052604090206149da858484614899565b83511580156149e95750825115155b15614aa95760068101805463ffffffff19164263ffffffff1617905560fc5460405163d71bb37b60e01b8152600481018790526001600160a01b039091169063d71bb37b90602401600060405180830381600087803b158015614a4b57600080fd5b505af1158015614a5f573d6000803e3d6000fd5b5060029250614a6c915050565b6005820154600160a01b900460ff166006811115614a8c57614a8c615714565b146143b55760405162461bcd60e51b81526004016106c990615b3b565b6006810154600090614ac290429063ffffffff16615dc3565b63ffffffff16856040015163ffffffff168660000151614ae29190615de8565b60408601518651614af99163ffffffff1690615de8565b614b039190615aa7565b614b0d9190615e5a565b60fc549091506001600160a01b031663c54c58c4614b2a886111f7565b600585015460405160e084901b6001600160e01b03191681526001600160a01b039283166004820152911660248201526044810189905260648101849052608401602060405180830381600087803b158015614b8557600080fd5b505af1158015614b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614bbd9190615d49565b6111af5760405162461bcd60e51b81526004016106c990615b3b565b600083815260ff60209081526040808320610100909252909120829055600581015484906001600160a01b0316614c0f826111f7565b600484015460058501546040805192835263ffffffff600160a81b90920482166020840152908816908201526001600160a01b0391909116907f3d051466fe86e1bd842d67e98121d69a930caccf48fc2ae2c83119b5a7b71af690606001611076565b6001600160a01b038216614cc85760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106c9565b6000818152606860205260409020546001600160a01b031615614d2d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106c9565b614d3960008383613e33565b6001600160a01b0382166000908152606960205260408120805460019290614d62908490615917565b909155505060008181526068602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115614df75750600090506003614ea4565b8460ff16601b14158015614e0f57508460ff16601c14155b15614e205750600090506004614ea4565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614e74573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614e9d57600060019250925050614ea4565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01614ece87828885614dc0565b935093505050935093915050565b828054614ee89061592f565b90600052602060002090601f016020900481019282614f0a5760008555614f50565b82601f10614f235782800160ff19823516178555614f50565b82800160010185558215614f50579182015b82811115614f50578235825591602001919060010190614f35565b50614f5c929150614fd4565b5090565b828054614f6c9061592f565b90600052602060002090601f016020900481019282614f8e5760008555614f50565b82601f10614fa757805160ff1916838001178555614f50565b82800160010185558215614f50579182015b82811115614f50578251825591602001919060010190614fb9565b5b80821115614f5c5760008155600101614fd5565b6001600160e01b03198116811461265357600080fd5b60006020828403121561501157600080fd5b81356113c981614fe9565b60006020828403121561502e57600080fd5b5035919050565b60005b83811015615050578181015183820152602001615038565b83811115610acd5750506000910152565b60008151808452615079816020860160208601615035565b601f01601f19169290920160200192915050565b6020815260006113c96020830184615061565b6001600160a01b038116811461265357600080fd5b600080604083850312156150c857600080fd5b82356150d3816150a0565b946020939093013593505050565b6000806000606084860312156150f657600080fd5b8335615101816150a0565b92506020840135615111816150a0565b929592945050506040919091013590565b60006020828403121561513457600080fd5b81356113c9816150a0565b60008083601f84011261515157600080fd5b50813567ffffffffffffffff81111561516957600080fd5b6020830191508360208285010111156146d757600080fd5b60008060006040848603121561519657600080fd5b83359250602084013567ffffffffffffffff8111156151b457600080fd5b6151c08682870161513f565b9497909650939450505050565b60008083601f8401126151df57600080fd5b50813567ffffffffffffffff8111156151f757600080fd5b6020830191508360208260051b85010111156146d757600080fd5b803563ffffffff8116811461522657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156152645761526461522b565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156152935761529361522b565b604052919050565b600067ffffffffffffffff8211156152b5576152b561522b565b50601f01601f191660200190565b600082601f8301126152d457600080fd5b81356152e76152e28261529b565b61526a565b8181528460208386010111156152fc57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600080600060c08a8c03121561533757600080fd5b8935985060208a013567ffffffffffffffff8082111561535657600080fd5b6153628d838e016151cd565b909a50985060408c013591508082111561537b57600080fd5b6153878d838e016151cd565b909850965086915061539b60608d01615212565b955060808c01359150808211156153b157600080fd5b6153bd8d838e016152c3565b945060a08c01359150808211156153d357600080fd5b506153e08c828d0161513f565b915080935050809150509295985092959850929598565b801515811461265357600080fd5b60008060006060848603121561541a57600080fd5b8335615425816150a0565b92506020840135615435816153f7565b915061544360408501615212565b90509250925092565b6000806040838503121561545f57600080fd5b8235915060208301356007811061547557600080fd5b809150509250929050565b60008060008060008060008060008060006101008c8e0312156154a257600080fd5b8b359a5067ffffffffffffffff8060208e013511156154c057600080fd5b6154d08e60208f01358f016151cd565b909b50995060408d01358110156154e657600080fd5b6154f68e60408f01358f016151cd565b909950975060608d0135965061550e60808e01615212565b95508060a08e0135111561552157600080fd5b6155318e60a08f01358f016152c3565b94508060c08e0135111561554457600080fd5b6155548e60c08f01358f016152c3565b93508060e08e0135111561556757600080fd5b506155788d60e08e01358e0161513f565b81935080925050509295989b509295989b9093969950565b600080604083850312156155a357600080fd5b823591506155b360208401615212565b90509250929050565b600080604083850312156155cf57600080fd5b82356155da816150a0565b91506020830135615475816153f7565b600080600080600080600080600060c08a8c03121561560857600080fd5b8935985060208a0135975060408a013567ffffffffffffffff8082111561562e57600080fd5b61563a8d838e016151cd565b909950975060608c013591508082111561565357600080fd5b61565f8d838e016151cd565b909750955060808c01359150808211156153b157600080fd5b6000806000806080858703121561568e57600080fd5b8435615699816150a0565b935060208501356156a9816150a0565b925060408501359150606085013567ffffffffffffffff8111156156cc57600080fd5b6156d8878288016152c3565b91505092959194509250565b6000806000606084860312156156f957600080fd5b8335615704816150a0565b92506020840135615435816150a0565b634e487b7160e01b600052602160045260246000fd5b6007811061574857634e487b7160e01b600052602160045260246000fd5b9052565b60408152825160408201526020830151606082015260408301516080820152606083015160a0820152608083015160c0820152600060a084015161579b60e08401826001600160a01b03169052565b5060c08401516101006157b08185018361572a565b60e086015191506101206157cb8186018463ffffffff169052565b908601519150610140906157e68583018463ffffffff169052565b86015191506101606157ff8582018463ffffffff169052565b9086015191506101809061581a8583018463ffffffff169052565b86015191506101a06158338582018463ffffffff169052565b8187015192506101c091508182860152615851610200860184615061565b90870151858203603f19016101e087015290925090506158718282615061565b925050506113c960208301846001600160a01b03169052565b6000806040838503121561589d57600080fd5b82356158a8816150a0565b91506020830135615475816150a0565b60208082526005908201526404282aaa8960db1b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000821982111561592a5761592a615901565b500190565b600181811c9082168061594357607f821691505b6020821081141561596457634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526010908201526f21494e56414c4944287374617475732960801b604082015260600190565b602080825260099082015268214d494e5f5445524d60b81b604082015260600190565b600063ffffffff80831681851681830481118215151615615a7657615a76615901565b02949350505050565b600063ffffffff808316818516808303821115615a9e57615a9e615901565b01949350505050565b600082821015615ab957615ab9615901565b500390565b66697066733a2f2f60c81b815260008251615ae0816007850160208701615035565b9190910160070192915050565b60208082526013908201527221494e56414c494428706c616e50726f6f662960681b604082015260600190565b600060208284031215615b2c57600080fd5b8151600381106113c957600080fd5b6020808252600e908201526d21554e50524f4345535341424c4560901b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020808385031215615c1357600080fd5b825167ffffffffffffffff80821115615c2b57600080fd5b9084019060608287031215615c3f57600080fd5b615c47615241565b8251615c52816150a0565b81528284015184820152604083015182811115615c6e57600080fd5b80840193505086601f840112615c8357600080fd5b82519150615c936152e28361529b565b8281528785848601011115615ca757600080fd5b615cb683868301878701615035565b60408201529695505050505050565b60008085851115615cd557600080fd5b83861115615ce257600080fd5b5050600583901b0193919092039150565b81835260006001600160fb1b03831115615d0c57600080fd5b8260051b8083602087013760009401602001938452509192915050565b8481528360208201526060604082015260006140a1606083018486615cf3565b600060208284031215615d5b57600080fd5b81516113c9816153f7565b6001600160a01b0386811682528516602082015263ffffffff84166040820152608060608201819052600090615d9f9083018486615cf3565b979650505050505050565b600060208284031215615dbc57600080fd5b5051919050565b600063ffffffff83811690831681811015615de057615de0615901565b039392505050565b600082615e0557634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906140a190830184615061565b600060208284031215615e4f57600080fd5b81516113c981614fe9565b6000816000190483118215151615615e7457615e74615901565b50029056fea2646970667358221220e4825e7b2c0443ab47bd26821b65a1aafb63d45486ee62c01414736184e97fef64736f6c63430008090033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.