Sepolia Testnet

Contract

0x5a3c35CCC5c05fDeFe5Ecafc15F4B1aC8eF71481
Source Code Source Code

Overview

ETH Balance

0 ETH

More Info

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Amount

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ZkVerifyAggregationGlobal

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
No with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "./ZkVerifyAggregationIsmp.sol";
import "./ZkVerifyAggregation.sol";

/**
 * @title ZkVerifyAggregationGlobal Contract
 * @notice It allows submitting and verifying aggregation proofs coming from zkVerify chain for both versions Ismp and Non Ismp one.
 */
contract ZkVerifyAggregationGlobal is Initializable, AccessControlUpgradeable, UUPSUpgradeable, IsmpGuest, BaseIsmpModule, ZkVerifyAggregationBase {

    /// @dev Role required for operator to submit/verify proofs.
    bytes32 public constant OPERATOR = keccak256("OPERATOR");

    /// @dev Role that allows upgrading the implementation
    bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");

    /// @notice State machine for source request
    bytes public constant STATE_MACHINE = bytes("SUBSTRATE-zkv_");

    /// @notice Batch submissions must have an equal number of ids to proof aggregations.
    error InvalidBatchCounts();

    // @notice Action is unauthorized
    error UnauthorizedAction();

    using Bytes for bytes;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /**
     * @notice Initialize the contract (replaces constructor)
     * @param _operator Operator for the contract
     * @param _ismpHost Ismp host contract address
     */
    function initialize(address _operator, address _ismpHost, address _upgrader) public initializer {
        __AccessControl_init();
        __UUPSUpgradeable_init();
        __IsmpGuest_init(_ismpHost);

        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(OPERATOR, _operator);
        _grantRole(UPGRADER_ROLE, _upgrader);
    }


    function host() public view override returns (address) {
        return getHost();
    }

    /**
     * @notice Submit Aggregation
     * @param _domainId the id of the domain
     * @param _aggregationId the id of the aggregation from the NewHorizen Relayer
     * @param _proofsAggregation aggregation of a set of proofs
     * @dev caller must have the OPERATOR role, admin can add caller via AccessControl.grantRole()
     */
    function submitAggregation(
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32 _proofsAggregation
    ) external onlyRole(OPERATOR) {
        _registerAggregation(_domainId, _aggregationId, _proofsAggregation);
    }

    /**
     * @notice Submit a Batch of aggregations, for a given domain Id, useful if a relayer needs to catch up.
     * @param _domainId id of domain
     * @param _aggregationIds ids of aggregations from the NewHorizen Relayer
     * @param _proofsAggregations a set of proofs
     * @dev caller must have the OPERATOR role, admin can add caller via AccessControl.grantRole()
     */
    function submitAggregationBatchByDomainId(
        uint256 _domainId,
        uint256[] calldata _aggregationIds,
        bytes32[] calldata _proofsAggregations
    ) external onlyRole(OPERATOR) {

        if(_aggregationIds.length != _proofsAggregations.length) {
            revert InvalidBatchCounts();
        }

        for (uint256 i; i < _aggregationIds.length;) {
            _registerAggregation(_domainId, _aggregationIds[i], _proofsAggregations[i]);
            unchecked {
                ++i;
            }
        }
    }

    /**
     * @notice Receive hyperbridge message containing an aggregation
     * @param incoming request from hyperbridge
     * @dev caller must be host address or risk critical vulnerabilities from unauthorized calls to this method by malicious actors.
     */
    function onAccept(IncomingPostRequest memory incoming) external override onlyHost {

        PostRequest memory request = incoming.request;
        if (!request.source.equals(STATE_MACHINE)) revert UnauthorizedAction();

        (uint256 _domainId, uint256 _aggregationId, bytes32 _proofsAggregation) = abi.decode(request.body, (uint256, uint256, bytes32));

        _registerAggregation(_domainId, _aggregationId, _proofsAggregation);
    }

    /**
     * @notice Function that allows the contract to be upgraded
     * @dev Only accounts with the UPGRADER_ROLE can call this function
     */
    function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(account),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 4 of 34 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 5 of 34 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

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

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

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

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// 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 {
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = MathUpgradeable.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.log256(value) + 1);
        }
    }

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

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 17 of 34 : IConsensusClient.sol
// Copyright (C) Polytope Labs Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pragma solidity ^0.8.17;

import {StateMachineHeight} from "./Message.sol";

// The state commiment identifies a commiment to some intermediate state in the state machine.
// This contains some metadata about the state machine like it's own timestamp at the time of this commitment.
struct StateCommitment {
	// This timestamp is useful for handling request timeouts.
	uint256 timestamp;
	// Overlay trie commitment to all ismp requests & response.
	bytes32 overlayRoot;
	// State trie commitment at the given block height
	bytes32 stateRoot;
}

// An intermediate state in the series of state transitions undergone by a given state machine.
struct IntermediateState {
	// the state machine identifier
	uint256 stateMachineId;
	// height of this state machine
	uint256 height;
	// state commitment
	StateCommitment commitment;
}

/**
 * @title The Ismp ConsensusClient
 * @author Polytope Labs ([email protected])
 *
 * @notice The consensus client interface responsible for the verification of consensus datagrams.
 * It's internals are opaque to the ISMP framework allowing it to evolve as needed.
 */
interface IConsensusClient {
	// @dev Given some opaque consensus proof, produce the new consensus state and newly finalized intermediate states.
	function verifyConsensus(
		bytes memory trustedState,
		bytes memory proof
	) external returns (bytes memory, IntermediateState[] memory);
}

// Copyright (C) Polytope Labs Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pragma solidity ^0.8.17;

import {PostRequest, StateMachineHeight} from "./Message.sol";

// @notice An object for dispatching post requests to the Hyperbridge
struct DispatchPost {
	// bytes representation of the destination state machine
	bytes dest;
	// the destination module
	bytes to;
	// the request body
	bytes body;
	// timeout for this request in seconds
	uint64 timeout;
	// the amount put up to be paid to the relayer,
	// this is charged in `IIsmpHost.feeToken` to `msg.sender`
	uint256 fee;
	// who pays for this request?
	address payer;
}

// @notice An object for dispatching get requests to the Hyperbridge
struct DispatchGet {
	// bytes representation of the destination state machine
	bytes dest;
	// height at which to read the state machine
	uint64 height;
	// storage keys to read
	bytes[] keys;
	// timeout for this request in seconds
	uint64 timeout;
	// Hyperbridge protocol fees for processing this request.
	uint256 fee;
	// Some application-specific metadata relating to this request
	bytes context;
}

struct DispatchPostResponse {
	// The request that initiated this response
	PostRequest request;
	// bytes for post response
	bytes response;
	// timeout for this response in seconds
	uint64 timeout;
	// the amount put up to be paid to the relayer,
	// this is charged in `IIsmpHost.feeToken` to `msg.sender`
	uint256 fee;
	// who pays for this request?
	address payer;
}

/*
 * @title The Ismp Dispatcher
 * @author Polytope Labs ([email protected])
 *
 * @notice The IDispatcher serves as the interface requests & response messages.
 */
interface IDispatcher {
	/**
	 * @return the host state machine id
	 */
	function host() external view returns (bytes memory);

	/**
	 * @dev Returns the address for the Uniswap V2 Router implementation used for swaps
	 * @return routerAddress - The address to the in-use RouterV02 implementation
	 */
	function uniswapV2Router() external view returns (address);

	/**
	 * @dev Returns the nonce immediately available for requests
	 * @return the `nonce`
	 */
	function nonce() external view returns (uint256);

	/**
	 * @dev Returns the address of the ERC-20 fee token contract configured for this state machine.
	 *
	 * @notice Hyperbridge collects it's dispatch fees in the provided token denomination. This will typically be in stablecoins.
	 *
	 * @return feeToken - The ERC20 contract address for fees.
	 */
	function feeToken() external view returns (address);

	/**
	 * @dev Returns the address of the per byte fee configured for the destination state machine.
	 *
	 * @notice Hyperbridge collects it's dispatch fees per every byte of the outgoing message.
	 *
	 * @param dest - The destination chain for the per byte fee.
	 * @return perByteFee - The per byte fee for outgoing messages.
	 */
	function perByteFee(bytes memory dest) external view returns (uint256);

	/**
	 * @dev Dispatch a POST request to Hyperbridge
	 *
	 * @notice Payment for the request can be made with either the native token or the IIsmpHost.feeToken.
	 * If native tokens are supplied, it will perform a swap under the hood using the local uniswap router.
	 * Will revert if enough native tokens are not provided.
	 *
	 * If no native tokens are provided then it will try to collect payment from the calling contract in
	 * the IIsmpHost.feeToken.
	 *
	 * @param request - post request
	 * @return commitment - the request commitment
	 */
	function dispatch(DispatchPost memory request) external payable returns (bytes32 commitment);

	/**
	 * @dev Dispatch a GET request to Hyperbridge
	 *
	 * @notice Payment for the request can be made with either the native token or the IIsmpHost.feeToken.
	 * If native tokens are supplied, it will perform a swap under the hood using the local uniswap router.
	 * Will revert if enough native tokens are not provided.
	 *
	 * If no native tokens are provided then it will try to collect payment from the calling contract in
	 * the IIsmpHost.feeToken.
	 *
	 * @param request - get request
	 * @return commitment - the request commitment
	 */
	function dispatch(DispatchGet memory request) external payable returns (bytes32 commitment);

	/**
	 * @dev Dispatch a POST response to Hyperbridge
	 *
	 * @notice Payment for the request can be made with either the native token or the IIsmpHost.feeToken.
	 * If native tokens are supplied, it will perform a swap under the hood using the local uniswap router.
	 * Will revert if enough native tokens are not provided.
	 *
	 * If no native tokens are provided then it will try to collect payment from the calling contract in
	 * the IIsmpHost.feeToken.
	 *
	 * @param response - post response
	 * @return commitment - the request commitment
	 */
	function dispatch(DispatchPostResponse memory response) external payable returns (bytes32 commitment);

	/**
	 * @dev Increase the relayer fee for a previously dispatched request.
	 * This is provided for use only on pending requests, such that when they timeout,
	 * the user can recover the entire relayer fee.
	 *
	 * @notice Payment can be made with either the native token or the IIsmpHost.feeToken.
	 * If native tokens are supplied, it will perform a swap under the hood using the local uniswap router.
	 * Will revert if enough native tokens are not provided.
	 *
	 * If no native tokens are provided then it will try to collect payment from the calling contract in
	 * the IIsmpHost.feeToken.
	 *
	 * If called on an already delivered request, these funds will be seen as a donation to the hyperbridge protocol.
	 * @param commitment - The request commitment
	 * @param amount - The amount provided in `IIsmpHost.feeToken()`
	 */
	function fundRequest(bytes32 commitment, uint256 amount) external payable;

	/**
	 * @dev Increase the relayer fee for a previously dispatched response.
	 * This is provided for use only on pending responses, such that when they timeout,
	 * the user can recover the entire relayer fee.
	 *
	 * @notice Payment can be made with either the native token or the IIsmpHost.feeToken.
	 * If native tokens are supplied, it will perform a swap under the hood using the local uniswap router.
	 * Will revert if enough native tokens are not provided.
	 *
	 * If no native tokens are provided then it will try to collect payment from the calling contract in
	 * the IIsmpHost.feeToken.
	 *
	 * If called on an already delivered response, these funds will be seen as a donation to the hyperbridge protocol.
	 * @param commitment - The response commitment
	 * @param amount - The amount to be provided in `IIsmpHost.feeToken()`
	 */
	function fundResponse(bytes32 commitment, uint256 amount) external payable;
}

// Copyright (C) Polytope Labs Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pragma solidity ^0.8.17;

import {StateCommitment, StateMachineHeight} from "./IConsensusClient.sol";
import {IDispatcher} from "./IDispatcher.sol";
import {PostRequest, PostResponse, GetResponse, GetRequest} from "./Message.sol";

// Some metadata about the request fee
struct FeeMetadata {
	// the relayer fee
	uint256 fee;
	// user who initiated the request
	address sender;
}

struct ResponseReceipt {
	// commitment of the response object
	bytes32 responseCommitment;
	// address of the relayer responsible for this response delivery
	address relayer;
}

// Various frozen states of the IIsmpHost
enum FrozenStatus {
	// Host is operating normally
	None,
	// Host is currently disallowing incoming datagrams
	Incoming,
	// Host is currently disallowing outgoing messages
	Outgoing,
	// All actions have been frozen
	All
}

/**
 * @title The Ismp Host Interface
 * @author Polytope Labs ([email protected])
 *
 * @notice The Ismp Host interface sits at the core of the interoperable state machine protocol,
 * It which encapsulates the interfaces required for ISMP datagram handlers and modules.
 *
 * @dev The IsmpHost provides the necessary storage interface for the ISMP handlers to process
 * ISMP messages, the IsmpDispatcher provides the interfaces applications use for dispatching requests
 * and responses. This host implementation delegates all verification logic to the IHandler contract.
 * It is only responsible for dispatching incoming & outgoing messages as well as managing
 * the state of the ISMP protocol.
 */
interface IIsmpHost is IDispatcher {
	/**
	 * @return the host admin
	 */
	function admin() external returns (address);

	/**
	 * @return the state machine identifier for the connected hyperbridge instance
	 */
	function hyperbridge() external view returns (bytes memory);

	/**
	 * @return the host timestamp
	 */
	function timestamp() external view returns (uint256);

	/**
	 * @dev Returns the fisherman responsible for vetoing the given state machine height.
	 * @return the `fisherman` address
	 */
	function vetoes(uint256 paraId, uint256 height) external view returns (address);

	/**
	 * @return the `frozen` status
	 */
	function frozen() external view returns (FrozenStatus);

	/**
	 * @dev Returns the fee required for 3rd party applications to access hyperbridge state commitments.
	 * @return the `stateCommitmentFee`
	 */
	function stateCommitmentFee() external view returns (uint256);

	/**
	 * @notice Charges the stateCommitmentFee to 3rd party applications.
	 * If native tokens are provided, will attempt to swap them for the stateCommitmentFee.
	 * If not enough native tokens are supplied, will revert.
	 *
	 * If no native tokens are provided then it will try to collect payment from the calling contract in
	 * the IIsmpHost.feeToken.
	 *
	 * @param height - state machine height
	 * @return the state commitment at `height`
	 */
	function stateMachineCommitment(StateMachineHeight memory height) external payable returns (StateCommitment memory);

	/**
	 * @param height - state machine height
	 * @return the state machine commitment update time at `height`
	 */
	function stateMachineCommitmentUpdateTime(StateMachineHeight memory height) external returns (uint256);

	/**
	 * @return the consensus client contract
	 */
	function consensusClient() external view returns (address);

	/**
	 * @return the last updated time of the consensus client
	 */
	function consensusUpdateTime() external view returns (uint256);

	/**
	 * @return the latest state machine height for the given stateMachineId. If it returns 0, the state machine is unsupported.
	 */
	function latestStateMachineHeight(uint256 stateMachineId) external view returns (uint256);

	/**
	 * @return the state of the consensus client
	 */
	function consensusState() external view returns (bytes memory);

	/**
	 * @dev Check the response status for a given request.
	 * @return `response` status
	 */
	function responded(bytes32 commitment) external view returns (bool);

	/**
	 * @param commitment - commitment to the request
	 * @return relayer address
	 */
	function requestReceipts(bytes32 commitment) external view returns (address);

	/**
	 * @param commitment - commitment to the request of the response
	 * @return response receipt
	 */
	function responseReceipts(bytes32 commitment) external view returns (ResponseReceipt memory);

	/**
	 * @param commitment - commitment to the request
	 * @return existence status of an outgoing request commitment
	 */
	function requestCommitments(bytes32 commitment) external view returns (FeeMetadata memory);

	/**
	 * @param commitment - commitment to the response
	 * @return existence status of an outgoing response commitment
	 */
	function responseCommitments(bytes32 commitment) external view returns (FeeMetadata memory);

	/**
	 * @return the challenge period
	 */
	function challengePeriod() external view returns (uint256);

	/**
	 * @return the unstaking period
	 */
	function unStakingPeriod() external view returns (uint256);

	/**
	 * @dev set the new frozen state of the host, only the admin or handler can call this.
	 * @param newState - the new frozen state
	 */
	function setFrozenState(FrozenStatus newState) external;

	/**
	 * @dev Store an encoded consensus state
	 * @param state new consensus state
	 */
	function storeConsensusState(bytes memory state) external;

	/**
	 * @dev Store the commitment at `state height`
	 * @param height state machine height
	 * @param commitment state commitment
	 */
	function storeStateMachineCommitment(StateMachineHeight memory height, StateCommitment memory commitment) external;

	/**
	 * @dev Delete the state commitment at given state height.
	 */
	function deleteStateMachineCommitment(StateMachineHeight memory height, address fisherman) external;

	/**
	 * @dev Dispatch an incoming request to destination module
	 * @param request - post request
	 */
	function dispatchIncoming(PostRequest memory request, address relayer) external;

	/**
	 * @dev Dispatch an incoming post response to source module
	 * @param response - post response
	 */
	function dispatchIncoming(PostResponse memory response, address relayer) external;

	/**
	 * @dev Dispatch an incoming get response to source module
	 * @param response - get response
	 */
	function dispatchIncoming(GetResponse memory response, address relayer) external;

	/**
	 * @dev Dispatch an incoming get timeout to source module
	 * @param timeout - timed-out get request
	 */
	function dispatchTimeOut(GetRequest memory timeout, FeeMetadata memory meta, bytes32 commitment) external;

	/**
	 * @dev Dispatch an incoming post timeout to source module
	 * @param timeout - timed-out post request
	 */
	function dispatchTimeOut(PostRequest memory timeout, FeeMetadata memory meta, bytes32 commitment) external;

	/**
	 * @dev Dispatch an incoming post response timeout to source module
	 * @param timeout - timed-out post response
	 */
	function dispatchTimeOut(PostResponse memory timeout, FeeMetadata memory meta, bytes32 commitment) external;
}

// Copyright (C) Polytope Labs Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pragma solidity ^0.8.17;

import {PostRequest, PostResponse, GetResponse, GetRequest} from "./Message.sol";
import {DispatchPost, DispatchPostResponse, DispatchGet, IDispatcher} from "./IDispatcher.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

struct IncomingPostRequest {
	// The Post request
	PostRequest request;
	// Relayer responsible for delivering the request
	address relayer;
}

struct IncomingPostResponse {
	// The Post response
	PostResponse response;
	// Relayer responsible for delivering the response
	address relayer;
}

struct IncomingGetResponse {
	// The Get response
	GetResponse response;
	// Relayer responsible for delivering the response
	address relayer;
}

interface IIsmpModule {
	/**
	 * @dev Called by the `IsmpHost` to notify a module of a new request the module may choose to respond immediately, or in a later block
	 * @param incoming post request
	 */
	function onAccept(IncomingPostRequest memory incoming) external;

	/**
	 * @dev Called by the `IsmpHost` to notify a module of a post response to a previously sent out request
	 * @param incoming post response
	 */
	function onPostResponse(IncomingPostResponse memory incoming) external;

	/**
	 * @dev Called by the `IsmpHost` to notify a module of a get response to a previously sent out request
	 * @param incoming get response
	 */
	function onGetResponse(IncomingGetResponse memory incoming) external;

	/**
	 * @dev Called by the `IsmpHost` to notify a module of post requests that were previously sent but have now timed-out
	 * @param request post request
	 */
	function onPostRequestTimeout(PostRequest memory request) external;

	/**
	 * @dev Called by the `IsmpHost` to notify a module of post requests that were previously sent but have now timed-out
	 * @param request post request
	 */
	function onPostResponseTimeout(PostResponse memory request) external;

	/**
	 * @dev Called by the `IsmpHost` to notify a module of get requests that were previously sent but have now timed-out
	 * @param request get request
	 */
	function onGetTimeout(GetRequest memory request) external;
}

/**
 * @dev Abstract contract to make implementing `IIsmpModule` easier.
 */
abstract contract BaseIsmpModule is IIsmpModule {
	/**
	 * @dev Call was not expected
	 */
	error UnexpectedCall();

	/**
	 * @dev Account is unauthorized
	 */
	error UnauthorizedCall();

	/**
	 * @dev restricts caller to the local `IsmpHost`
	 */
	modifier onlyHost() {
		if (msg.sender != host()) revert UnauthorizedCall();
		_;
	}

	constructor() {
		address hostAddr = host();
		if (hostAddr != address(0)) {
			// approve the host infintely
			IERC20(IDispatcher(hostAddr).feeToken()).approve(hostAddr, type(uint256).max);
		}
	}

	/**
	 * @dev Should return the `IsmpHost` address for the current chain.
	 * The `IsmpHost` is an immutable contract that will never change.
	 */
	function host() public view virtual returns (address);

	/**
	 * @dev returns the quoted fee for dispatching a POST request
	 */
	function quote(DispatchPost memory request) public view returns (uint256) {
		uint256 len = 32 > request.body.length ? 32 : request.body.length;
		return request.fee + (len * IDispatcher(host()).perByteFee(request.dest));
	}

	/**
	 * @dev returns the quoted fee for dispatching a GET request
	 */
	function quote(DispatchGet memory request) public view returns (uint256) {
		uint256 pbf = IDispatcher(host()).perByteFee(IDispatcher(host()).host());
		uint256 minimumFee = 32 * pbf;
		uint256 totalFee = request.fee + (pbf * request.context.length);
		return minimumFee > totalFee ? minimumFee : totalFee;
	}

	/**
	 * @dev returns the quoted fee for dispatching a POST response
	 */
	function quote(DispatchPostResponse memory response) public view returns (uint256) {
		uint256 len = 32 > response.response.length ? 32 : response.response.length;
		return response.fee + (len * IDispatcher(host()).perByteFee(response.request.source));
	}

	function onAccept(IncomingPostRequest calldata) external virtual onlyHost {
		revert UnexpectedCall();
	}

	function onPostRequestTimeout(PostRequest memory) external virtual onlyHost {
		revert UnexpectedCall();
	}

	function onPostResponse(IncomingPostResponse memory) external virtual onlyHost {
		revert UnexpectedCall();
	}

	function onPostResponseTimeout(PostResponse memory) external virtual onlyHost {
		revert UnexpectedCall();
	}

	function onGetResponse(IncomingGetResponse memory) external virtual onlyHost {
		revert UnexpectedCall();
	}

	function onGetTimeout(GetRequest memory) external virtual onlyHost {
		revert UnexpectedCall();
	}
}

// Copyright (C) Polytope Labs Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pragma solidity ^0.8.17;

import {StorageValue} from "@polytope-labs/solidity-merkle-trees/src/Types.sol";

// Identifies some state machine height. We allow for a state machine identifier here
// as some consensus clients may track multiple, concurrent state machines.
struct StateMachineHeight {
	// the state machine identifier
	uint256 stateMachineId;
	// height of this state machine
	uint256 height;
}

struct PostRequest {
	// the source state machine of this request
	bytes source;
	// the destination state machine of this request
	bytes dest;
	// request nonce
	uint64 nonce;
	// Module Id of this request origin
	bytes from;
	// destination module id
	bytes to;
	// timestamp by which this request times out.
	uint64 timeoutTimestamp;
	// request body
	bytes body;
}

struct GetRequest {
	// the source state machine of this request
	bytes source;
	// the destination state machine of this request
	bytes dest;
	// request nonce
	uint64 nonce;
	// Module Id of this request origin
	address from;
	// timestamp by which this request times out.
	uint64 timeoutTimestamp;
	// Storage keys to read.
	bytes[] keys;
	// height at which to read destination state machine
	uint64 height;
	// Some application-specific metadata relating to this request
	bytes context;
}

struct GetResponse {
	// The request that initiated this response
	GetRequest request;
	// storage values for get response
	StorageValue[] values;
}

struct PostResponse {
	// The request that initiated this response
	PostRequest request;
	// bytes for post response
	bytes response;
	// timestamp by which this response times out.
	uint64 timeoutTimestamp;
}

// A post request as a leaf in a merkle tree
struct PostRequestLeaf {
	// The request
	PostRequest request;
	// It's index in the mmr leaves
	uint256 index;
	// it's k-index
	uint256 kIndex;
}

// A post response as a leaf in a merkle tree
struct PostResponseLeaf {
	// The response
	PostResponse response;
	// It's index in the mmr leaves
	uint256 index;
	// it's k-index
	uint256 kIndex;
}

// A get response as a leaf in a merkle mountain range tree
struct GetResponseLeaf {
	// The response
	GetResponse response;
	// It's index in the mmr leaves
	uint256 index;
	// it's k-index
	uint256 kIndex;
}

// A merkle mountain range proof.
struct Proof {
	// height of the state machine
	StateMachineHeight height;
	// the multi-proof
	bytes32[] multiproof;
	// The total number of leaves in the mmr for this proof.
	uint256 leafCount;
}

// A message for handling incoming requests
struct PostRequestMessage {
	// proof for the requests
	Proof proof;
	// The requests, contained in the merkle mountain range tree
	PostRequestLeaf[] requests;
}

// A message for handling incoming GET responses
struct GetResponseMessage {
	// proof for the responses
	Proof proof;
	// The responses, contained in the merkle mountain range tree
	GetResponseLeaf[] responses;
}

struct GetTimeoutMessage {
	// requests which have timed-out
	GetRequest[] timeouts;
	// the height of the state machine proof
	StateMachineHeight height;
	// non-membership proof of the requests
	bytes[] proof;
}

struct PostRequestTimeoutMessage {
	// requests which have timed-out
	PostRequest[] timeouts;
	// the height of the state machine proof
	StateMachineHeight height;
	// non-membership proof of the requests
	bytes[] proof;
}

struct PostResponseTimeoutMessage {
	// responses which have timed-out
	PostResponse[] timeouts;
	// the height of the state machine proof
	StateMachineHeight height;
	// non-membership proof of the requests
	bytes[] proof;
}

// A message for handling incoming responses
struct PostResponseMessage {
	// proof for the responses
	Proof proof;
	// the responses, contained in a merkle tree leaf
	PostResponseLeaf[] responses;
}

library Message {
	/**
	 * @dev Calculates the absolute timeout value for a PostRequest
	 */
	function timeout(PostRequest memory req) internal pure returns (uint64) {
		if (req.timeoutTimestamp == 0) {
			return type(uint64).max;
		} else {
			return req.timeoutTimestamp;
		}
	}

	/**
	 * @dev Calculates the absolute timeout value for a GetRequest
	 */
	function timeout(GetRequest memory req) internal pure returns (uint64) {
		if (req.timeoutTimestamp == 0) {
			return type(uint64).max;
		} else {
			return req.timeoutTimestamp;
		}
	}

	/**
	 * @dev Calculates the absolute timeout value for a PostResponse
	 */
	function timeout(PostResponse memory res) internal pure returns (uint64) {
		if (res.timeoutTimestamp == 0) {
			return type(uint64).max;
		} else {
			return res.timeoutTimestamp;
		}
	}

	/**
	 * @dev Encode the given post request for commitment
	 */
	function encode(PostRequest memory req) internal pure returns (bytes memory) {
		return abi.encodePacked(req.source, req.dest, req.nonce, req.timeoutTimestamp, req.from, req.to, req.body);
	}

	/**
	 * @dev Encode the given get request for commitment
	 */
	function encode(GetRequest memory req) internal pure returns (bytes memory) {
		bytes memory keysEncoding = bytes("");
		uint256 len = req.keys.length;
		for (uint256 i = 0; i < len; i++) {
			keysEncoding = bytes.concat(keysEncoding, req.keys[i]);
		}

		return
			abi.encodePacked(
				req.source,
				req.dest,
				req.nonce,
				req.height,
				req.timeoutTimestamp,
				abi.encodePacked(req.from),
				keysEncoding,
				req.context
			);
	}

	/**
	 * @dev Returns the commitment for the given post response
	 */
	function hash(PostResponse memory res) internal pure returns (bytes32) {
		return keccak256(bytes.concat(encode(res.request), abi.encodePacked(res.response, res.timeoutTimestamp)));
	}

	/**
	 * @dev Returns the commitment for the given post request
	 */
	function hash(PostRequest memory req) internal pure returns (bytes32) {
		return keccak256(encode(req));
	}

	/**
	 * @dev Returns the commitment for the given get request
	 */
	function hash(GetRequest memory req) internal pure returns (bytes32) {
		return keccak256(encode(req));
	}

	/**
	 * @dev Returns the commitment for the given get response
	 */
	function hash(GetResponse memory res) internal pure returns (bytes32) {
		bytes memory response = bytes("");
		uint256 len = res.values.length;
		for (uint256 i = 0; i < len; i++) {
			response = bytes.concat(response, bytes.concat(res.values[i].key, res.values[i].value));
		}
		return keccak256(bytes.concat(encode(res.request), response));
	}
}

pragma solidity ^0.8.17;

// SPDX-License-Identifier: Apache2

import {Memory} from "./Memory.sol";

struct ByteSlice {
    bytes data;
    uint256 offset;
}

library Bytes {
    uint256 internal constant BYTES_HEADER_SIZE = 32;

    // Checks if two `bytes memory` variables are equal. This is done using hashing,
    // which is much more gas efficient then comparing each byte individually.
    // Equality means that:
    //  - 'self.length == other.length'
    //  - For 'n' in '[0, self.length)', 'self[n] == other[n]'
    function equals(
        bytes memory self,
        bytes memory other
    ) internal pure returns (bool equal) {
        if (self.length != other.length) {
            return false;
        }
        uint256 addr;
        uint256 addr2;
        assembly {
            addr := add(self, /*BYTES_HEADER_SIZE*/ 32)
            addr2 := add(other, /*BYTES_HEADER_SIZE*/ 32)
        }
        equal = Memory.equals(addr, addr2, self.length);
    }

    function readByte(ByteSlice memory self) internal pure returns (uint8) {
        if (self.offset + 1 > self.data.length) {
            revert("Out of range");
        }

        uint8 b = uint8(self.data[self.offset]);
        self.offset += 1;

        return b;
    }

    // Copies 'len' bytes from 'self' into a new array, starting at the provided 'startIndex'.
    // Returns the new copy.
    // Requires that:
    //  - 'startIndex + len <= self.length'
    // The length of the substring is: 'len'
    function read(
        ByteSlice memory self,
        uint256 len
    ) internal pure returns (bytes memory) {
        require(self.offset + len <= self.data.length);
        if (len == 0) {
            return "";
        }
        uint256 addr = Memory.dataPtr(self.data);
        bytes memory slice = Memory.toBytes(addr + self.offset, len);
        self.offset += len;
        return slice;
    }

    // Copies a section of 'self' into a new array, starting at the provided 'startIndex'.
    // Returns the new copy.
    // Requires that 'startIndex <= self.length'
    // The length of the substring is: 'self.length - startIndex'
    function substr(
        bytes memory self,
        uint256 startIndex
    ) internal pure returns (bytes memory) {
        require(startIndex <= self.length);
        uint256 len = self.length - startIndex;
        uint256 addr = Memory.dataPtr(self);
        return Memory.toBytes(addr + startIndex, len);
    }

    // Copies 'len' bytes from 'self' into a new array, starting at the provided 'startIndex'.
    // Returns the new copy.
    // Requires that:
    //  - 'startIndex + len <= self.length'
    // The length of the substring is: 'len'
    function substr(
        bytes memory self,
        uint256 startIndex,
        uint256 len
    ) internal pure returns (bytes memory) {
        require(startIndex + len <= self.length);
        if (len == 0) {
            return "";
        }
        uint256 addr = Memory.dataPtr(self);
        return Memory.toBytes(addr + startIndex, len);
    }

    // Combines 'self' and 'other' into a single array.
    // Returns the concatenated arrays:
    //  [self[0], self[1], ... , self[self.length - 1], other[0], other[1], ... , other[other.length - 1]]
    // The length of the new array is 'self.length + other.length'
    function concat(
        bytes memory self,
        bytes memory other
    ) internal pure returns (bytes memory) {
        bytes memory ret = new bytes(self.length + other.length);
        uint256 src;
        uint256 srcLen;
        (src, srcLen) = Memory.fromBytes(self);
        uint256 src2;
        uint256 src2Len;
        (src2, src2Len) = Memory.fromBytes(other);
        uint256 dest;
        (dest, ) = Memory.fromBytes(ret);
        uint256 dest2 = dest + srcLen;
        Memory.copy(src, dest, srcLen);
        Memory.copy(src2, dest2, src2Len);
        return ret;
    }

    function toBytes32(bytes memory self) internal pure returns (bytes32 out) {
        require(self.length >= 32, "Bytes:: toBytes32: data is to short.");
        assembly {
            out := mload(add(self, 32))
        }
    }

    function toBytes16(
        bytes memory self,
        uint256 offset
    ) internal pure returns (bytes16 out) {
        for (uint256 i = 0; i < 16; i++) {
            out |= bytes16(bytes1(self[offset + i]) & 0xFF) >> (i * 8);
        }
    }

    function toBytes8(
        bytes memory self,
        uint256 offset
    ) internal pure returns (bytes8 out) {
        for (uint256 i = 0; i < 8; i++) {
            out |= bytes8(bytes1(self[offset + i]) & 0xFF) >> (i * 8);
        }
    }

    function toBytes4(
        bytes memory self,
        uint256 offset
    ) internal pure returns (bytes4) {
        bytes4 out;

        for (uint256 i = 0; i < 4; i++) {
            out |= bytes4(self[offset + i] & 0xFF) >> (i * 8);
        }
        return out;
    }

    function toBytes2(
        bytes memory self,
        uint256 offset
    ) internal pure returns (bytes2) {
        bytes2 out;

        for (uint256 i = 0; i < 2; i++) {
            out |= bytes2(self[offset + i] & 0xFF) >> (i * 8);
        }
        return out;
    }

    function removeLeadingZero(
        bytes memory data
    ) internal pure returns (bytes memory) {
        uint256 length = data.length;

        uint256 startIndex = 0;
        for (uint256 i = 0; i < length; i++) {
            if (data[i] != 0) {
                startIndex = i;
                break;
            }
        }

        return substr(data, startIndex);
    }

    function removeEndingZero(
        bytes memory data
    ) internal pure returns (bytes memory) {
        uint256 length = data.length;

        uint256 endIndex = 0;
        for (uint256 i = length - 1; i >= 0; i--) {
            if (data[i] != 0) {
                endIndex = i;
                break;
            }
        }

        return substr(data, 0, endIndex + 1);
    }

    function reverse(
        bytes memory inbytes
    ) internal pure returns (bytes memory) {
        uint256 inlength = inbytes.length;
        bytes memory outbytes = new bytes(inlength);

        for (uint256 i = 0; i <= inlength - 1; i++) {
            outbytes[i] = inbytes[inlength - i - 1];
        }

        return outbytes;
    }
}

pragma solidity ^0.8.17;

// SPDX-License-Identifier: Apache2

library Memory {
    uint256 internal constant WORD_SIZE = 32;

    // Compares the 'len' bytes starting at address 'addr' in memory with the 'len'
    // bytes starting at 'addr2'.
    // Returns 'true' if the bytes are the same, otherwise 'false'.
    function equals(
        uint256 addr,
        uint256 addr2,
        uint256 len
    ) internal pure returns (bool equal) {
        assembly {
            equal := eq(keccak256(addr, len), keccak256(addr2, len))
        }
    }

    // Compares the 'len' bytes starting at address 'addr' in memory with the bytes stored in
    // 'bts'. It is allowed to set 'len' to a lower value then 'bts.length', in which case only
    // the first 'len' bytes will be compared.
    // Requires that 'bts.length >= len'

    function equals(
        uint256 addr,
        uint256 len,
        bytes memory bts
    ) internal pure returns (bool equal) {
        require(bts.length >= len);
        uint256 addr2;
        assembly {
            addr2 := add(bts, /*BYTES_HEADER_SIZE*/ 32)
        }
        return equals(addr, addr2, len);
    }
    // Returns a memory pointer to the data portion of the provided bytes array.

    function dataPtr(bytes memory bts) internal pure returns (uint256 addr) {
        assembly {
            addr := add(bts, /*BYTES_HEADER_SIZE*/ 32)
        }
    }

    // Creates a 'bytes memory' variable from the memory address 'addr', with the
    // length 'len'. The function will allocate new memory for the bytes array, and
    // the 'len bytes starting at 'addr' will be copied into that new memory.
    function toBytes(
        uint256 addr,
        uint256 len
    ) internal pure returns (bytes memory bts) {
        bts = new bytes(len);
        uint256 btsptr;
        assembly {
            btsptr := add(bts, /*BYTES_HEADER_SIZE*/ 32)
        }
        copy(addr, btsptr, len);
    }

    // Copies 'self' into a new 'bytes memory'.
    // Returns the newly created 'bytes memory'
    // The returned bytes will be of length '32'.
    function toBytes(bytes32 self) internal pure returns (bytes memory bts) {
        bts = new bytes(32);
        assembly {
            mstore(add(bts, /*BYTES_HEADER_SIZE*/ 32), self)
        }
    }

    // Copy 'len' bytes from memory address 'src', to address 'dest'.
    // This function does not check the or destination, it only copies
    // the bytes.
    function copy(uint256 src, uint256 dest, uint256 len) internal pure {
        // Copy word-length chunks while possible
        for (; len >= WORD_SIZE; len -= WORD_SIZE) {
            assembly {
                mstore(dest, mload(src))
            }
            dest += WORD_SIZE;
            src += WORD_SIZE;
        }

        // Copy remaining bytes
        uint256 mask = len == 0
            ? 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
            : 256 ** (WORD_SIZE - len) - 1;
        assembly {
            let srcpart := and(mload(src), not(mask))
            let destpart := and(mload(dest), mask)
            mstore(dest, or(destpart, srcpart))
        }
    }

    // This function does the same as 'dataPtr(bytes memory)', but will also return the
    // length of the provided bytes array.
    function fromBytes(
        bytes memory bts
    ) internal pure returns (uint256 addr, uint256 len) {
        len = bts.length;
        assembly {
            addr := add(bts, /*BYTES_HEADER_SIZE*/ 32)
        }
    }
}

File 24 of 34 : Types.sol
pragma solidity ^0.8.17;

// SPDX-License-Identifier: Apache2

// Outcome of a successfully verified merkle-patricia proof
struct StorageValue {
    // the storage key
    bytes key;
    // the encoded value
    bytes value;
}

/// @title A representation of a Merkle tree node
struct Node {
    // Distance of the node to the leftmost node
    uint256 k_index;
    // A hash of the node itself
    bytes32 node;
}

/// @title A representation of a MerkleMountainRange leaf
struct MmrLeaf {
    // the leftmost index of a node
    uint256 k_index;
    // The position in the tree
    uint256 leaf_index;
    // The hash of the position in the tree
    bytes32 hash;
}

struct Iterator {
    uint256 offset;
    bytes32[] data;
}

// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

import "../lib/Merkle.sol";

abstract contract ZkVerifyAggregationBase {

    /// @notice Mapping of domain Ids to aggregationIds to proofsAggregations.
    mapping(uint256 => mapping(uint256 => bytes32)) public proofsAggregations;

    /// @notice Emitted when a new aggregation is posted.
    /// @param _domainId Event domainId.
    /// @param _aggregationId Event aggregationId.
    /// @param _proofsAggregation Aggregated proofs.
    event AggregationPosted(uint256 indexed _domainId, uint256 indexed _aggregationId, bytes32 indexed _proofsAggregation);

    /**
    * @notice Construct a new ZkVerifyAggregationBase contract
    */
    constructor() {}

    /**
     * @notice Verify a proof against a stored merkle tree
     * @param _domainId the id of the domain from the Horizen main chain
     * @param _aggregationId the id of the aggregation from the Horizen main chain
     * @param _leaf of the merkle tree
     * @param _merklePath path from leaf to root of the merkle tree
     * @param _leafCount the number of leaves in the merkle tree
     * @param _index the 0 indexed `index`'th leaf from the bottom left of the tree, see test cases.
    */
    function verifyProofAggregation(
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32 _leaf,
        bytes32[] calldata _merklePath,
        uint256 _leafCount,
        uint256 _index
    ) external view returns (bool) {
        // Load the proofsAggregation at the given domain Id and aggregationId.
        bytes32 proofsAggregation = proofsAggregations[_domainId][_aggregationId];

        // Verify the proofsAggregations/path.
        return Merkle.verifyProofKeccak(proofsAggregation, _merklePath, _leafCount, _index, _leaf);
    }

    function _registerAggregation(
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32 _proofsAggregation
    ) internal {
        proofsAggregations[_domainId][_aggregationId] = _proofsAggregation;

        emit AggregationPosted(_domainId, _aggregationId, _proofsAggregation);
    }
}

File 26 of 34 : IVerifyProofAggregation.sol
// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

interface IVerifyProofAggregation {
    function verifyProofAggregation(
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32 _leaf,
        bytes32[] calldata _merklePath,
        uint256 _leafCount,
        uint256 _index
    ) external view returns (bool);
}

// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

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

contract IsmpGuest  is Initializable {
    address private _host;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /**
     * @notice Initialize the IsmpGuest contract
     * @param _ismpHost The address of the ISMP host
     */
    function __IsmpGuest_init(address _ismpHost) internal onlyInitializing {
        _host = _ismpHost;
    }

    function getHost() public view returns (address) {
        return _host;
    }
}

// SPDX-License-Identifier: Apache-2.0
// Adapted from Substrate's binary_merkle_tree (last updated v 15.0.0) (https://docs.rs/binary-merkle-tree/latest/binary_merkle_tree/)

pragma solidity ^0.8.0;

/**
 * @dev This function deals with verification of Merkle Tree proofs
 *      Specifically for Substrate's binary-merkle-tree v15.0.0
 */
library Merkle {

    /// @notice Guard error for empty proofs
    error IndexOutOfBounds();

    function verifyProofKeccak(
        bytes32 root,
        bytes32[] calldata proof,
        uint256 numberOfLeaves,
        uint256 leafIndex,
        bytes32 leaf
    ) internal pure returns (bool) {

        if (leafIndex >= numberOfLeaves) {
            revert IndexOutOfBounds();
        }

        bytes32 computedHash = keccak256(abi.encodePacked(leaf));

        uint256 position = leafIndex;
        uint256 width = numberOfLeaves;

        uint256 limit = proof.length;
        for (uint256 i; i < limit;) {
            bytes32 proofElement = proof[i];

            if (position % 2 == 1 || position + 1 == width) {
                computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
            } else {
                computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
            }

            position /= 2;
            width = (width - 1) / 2 + 1;

            unchecked {
                ++i;
            }
        }

        return computedHash == root;
    }

}

// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

import "../interfaces/IVerifyProofAggregation.sol";

struct Args {
    uint256 domainId;
    uint256 aggregationId;
    bytes32 leaf;
    bytes32[] merklePath;
    uint256 leafCount;
    uint256 index;
}

contract VerifyProofAggregationMock is IVerifyProofAggregation {
    uint256 domainId;
    uint256 aggregationId;
    bytes32 leaf;
    bytes32[] merklePath;
    uint256 leafCount;
    uint256 index;

    function verifyProofAggregation(
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32 _leaf,
        bytes32[] calldata _merklePath,
        uint256 _leafCount,
        uint256 _index
    ) external view returns (bool) {
        require(_domainId == domainId, "domainId mismatch");
        require(_aggregationId == aggregationId, "aggregationId mismatch");
        require(_leaf == leaf, "aggregationId mismatch");
        require(_merklePath.length == merklePath.length, "merklePath length mismatch");
        for (uint256 i = 0; i != _merklePath.length; i++) {
            require(_merklePath[i] == merklePath[i], "merklePath mismatch");
        }
        require(_leafCount == leafCount, "leafCount mismatch");
        require(_index == index, "index mismatch");
        return true;
    }

    function setExpectedArgs(Args calldata args) public {
        domainId = args.domainId;
        aggregationId = args.aggregationId;
        leaf = args.leaf;
        delete merklePath;
        for (uint256 i = 0; i != args.merklePath.length; i++) {
            merklePath.push(args.merklePath[i]);
        }
        leafCount = args.leafCount;
        index = args.index;
    }
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "../interfaces/IVerifyProofAggregation.sol";

contract ZkVerifyGroth16 {
    IVerifyProofAggregation immutable zkVerifyAggregation;

    bytes32 constant PROVING_SYSTEM_ID = keccak256(abi.encodePacked("groth16"));

    /**
     * @notice Construct a ZkVerifyGroth16 contract
     * @param _zkVerifyAggregation the address of the zkVerifyAggregation contract instance
     */
    constructor(address _zkVerifyAggregation) {
        zkVerifyAggregation = IVerifyProofAggregation(_zkVerifyAggregation);
    }

    /**
     * @notice Verify a Groth16 proof submitted to ZkVerify chain
     * @param _vkHash the hash of the verification key
     * @param _inputs the public inputs, as a list of field elements
     * @param _domainId the id of the domain (from zkVerify chain)
     * @param _aggregationId the id of the aggregation (from zkVerify chain)
     * @param _merklePath path from leaf to root of the merkle tree (from zkVerify chain)
     * @param _leafCount the number of leaves in the merkle tree (from zkVerify chain)
     * @param _index the index of the proof inside the merkle tree (from zkVerify chain)
     * @return bool the result of the verification
     */
    function verify(
        bytes32 _vkHash,
        uint256[] memory _inputs,
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32[] calldata _merklePath,
        uint256 _leafCount,
        uint256 _index
    ) public view returns (bool) {
        bytes32 leaf = statementHash(_vkHash, _inputs);
        return
            zkVerifyAggregation.verifyProofAggregation(_domainId, _aggregationId, leaf, _merklePath, _leafCount, _index);
    }

    /**
     * @notice Compute the statement hash associated to a Groth16 proof
     * @param vkHash the hash of the verification key
     * @param inputs the public inputs, as a list of field elements
     * @return bytes32 the statement hash
     */
    function statementHash(bytes32 vkHash, uint256[] memory inputs) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(PROVING_SYSTEM_ID, vkHash, keccak256(encodePublicInputs(inputs))));
    }

    /**
     * @notice Encode the public inputs of a Groth16 proof
     * @param inputs the public inputs, as a list of field elements
     * @return bytes the encoded public inputs
     */
    function encodePublicInputs(uint256[] memory inputs) public pure returns (bytes memory) {
        uint256 numInputs = inputs.length;
        bytes32[] memory encodedInputs = new bytes32[](numInputs);
        for (uint256 i = 0; i != numInputs; i++) {
            encodedInputs[i] = _changeEndianess(inputs[i]);
        }
        return abi.encodePacked(encodedInputs);
    }

    function _changeEndianess(uint256 input) internal pure returns (bytes32 out) {
        out = bytes32(input);
        // swap bytes
        out = ((out & 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00) >> 8)
            | ((out & 0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff) << 8);
        // swap 2-byte long pairs
        out = ((out & 0xffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000) >> 16)
            | ((out & 0x0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff) << 16);
        // swap 4-byte long pairs
        out = ((out & 0xffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000) >> 32)
            | ((out & 0x00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff) << 32);
        // swap 8-byte long pairs
        out = ((out & 0xffffffffffffffff0000000000000000ffffffffffffffff0000000000000000) >> 64)
            | ((out & 0x0000000000000000ffffffffffffffff0000000000000000ffffffffffffffff) << 64);
        // swap 16-byte long pairs
        out = (out >> 128) | (out << 128);
    }
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "../interfaces/IVerifyProofAggregation.sol";

contract ZkVerifyRisc0 {
    IVerifyProofAggregation immutable zkVerifyAggregation;

    bytes32 constant PROVING_SYSTEM_ID = keccak256(abi.encodePacked("risc0"));

    /**
     * @notice Construct a ZkVerifyRisc0 contract
     * @param _zkVerifyAggregation the address of the zkVerifyAggregation contract instance
     */
    constructor(address _zkVerifyAggregation) {
        zkVerifyAggregation = IVerifyProofAggregation(_zkVerifyAggregation);
    }

    /**
     * @notice Verify a Risc0 proof submitted to ZkVerify chain
     * @param _vkHash the hash of the verification key
     * @param _inputs the public inputs, as found in the risc0 journal
     * @param _version the verifier version (e.g. "risc0:v1.1")
     * @param _domainId the id of the domain (from zkVerify chain)
     * @param _aggregationId the id of the aggregation (from zkVerify chain)
     * @param _merklePath path from leaf to root of the merkle tree (from zkVerify chain)
     * @param _leafCount the number of leaves in the merkle tree (from zkVerify chain)
     * @param _index the index of the proof inside the merkle tree (from zkVerify chain)
     * @return bool the result of the verification
     */
    function verify(
        bytes32 _vkHash,
        string memory _version,
        bytes memory _inputs,
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32[] calldata _merklePath,
        uint256 _leafCount,
        uint256 _index
    ) public view returns (bool) {
        bytes32 leaf = statementHash(_vkHash, _version, _inputs);
        return
            zkVerifyAggregation.verifyProofAggregation(_domainId, _aggregationId, leaf, _merklePath, _leafCount, _index);
    }

    /**
     * @notice Compute the statement hash associated to a Risc0 proof
     * @param vk the hash of the verification key
     * @param version the verifier version (e.g. "risc0:v1.1")
     * @param inputs the public inputs, as found in the risc0 journal
     * @return bytes32 the statement hash
     */
    function statementHash(bytes32 vk, string memory version, bytes memory inputs) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(PROVING_SYSTEM_ID, vk, sha256(bytes(version)), keccak256(inputs)));
    }
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "../interfaces/IVerifyProofAggregation.sol";

contract ZkVerifyUltraplonk {
    IVerifyProofAggregation immutable zkVerifyAggregation;

    bytes32 constant PROVING_SYSTEM_ID = keccak256(abi.encodePacked("ultraplonk"));

    /**
     * @notice Construct a ZkVerifyUltraplonk contract
     * @param _zkVerifyAggregation the address of the zkVerifyAggregation contract instance
     */
    constructor(address _zkVerifyAggregation) {
        zkVerifyAggregation = IVerifyProofAggregation(_zkVerifyAggregation);
    }

    /**
     * @notice Verify a Ultraplonk proof submitted to ZkVerify chain
     * @param _vkHash the hash of the verification key
     * @param _inputs the public inputs, as a list of field elements
     * @param _domainId the id of the domain (from zkVerify chain)
     * @param _aggregationId the id of the aggregation (from zkVerify chain)
     * @param _merklePath path from leaf to root of the merkle tree (from zkVerify chain)
     * @param _leafCount the number of leaves in the merkle tree (from zkVerify chain)
     * @param _index the index of the proof inside the merkle tree (from zkVerify chain)
     * @return bool the result of the verification
     */
    function verify(
        bytes32 _vkHash,
        uint256[] memory _inputs,
        uint256 _domainId,
        uint256 _aggregationId,
        bytes32[] calldata _merklePath,
        uint256 _leafCount,
        uint256 _index
    ) public view returns (bool) {
        bytes32 leaf = statementHash(_vkHash, _inputs);
        return
            zkVerifyAggregation.verifyProofAggregation(_domainId, _aggregationId, leaf, _merklePath, _leafCount, _index);
    }

    /**
     * @notice Compute the statement hash associated to a Ultraplonk proof
     * @param vkHash the hash of the verification key
     * @param inputs the public inputs, as a list of field elements
     * @return bytes32 the statement hash
     */
    function statementHash(bytes32 vkHash, uint256[] memory inputs) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(PROVING_SYSTEM_ID, vkHash, keccak256(encodePublicInputs(inputs))));
    }

    /**
     * @notice Encode the public inputs of a Ultraplonk proof
     * @param inputs the public inputs, as a list of field elements
     * @return bytes the encoded public inputs
     */
    function encodePublicInputs(uint256[] memory inputs) public pure returns (bytes memory) {
        return abi.encodePacked(inputs);
    }
}

// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

import "./abstract/ZkVerifyAggregationBase.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "./lib/Merkle.sol";

/**
 * @title ZkVerifyAggregation Contract
 * @notice It allows submitting and verifying aggregation proofs coming from zkVerify chain.
 */
contract ZkVerifyAggregation is Initializable, AccessControlUpgradeable, UUPSUpgradeable, ZkVerifyAggregationBase {

   /// @dev Role required for operator to submit/verify proofs.
   bytes32 public constant OPERATOR = keccak256("OPERATOR");

   /// @dev Role that allows upgrading the implementation
   bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");

   /// @notice Batch submissions must have an equal number of ids to proof aggregations.
   error InvalidBatchCounts();

   /// @custom:oz-upgrades-unsafe-allow constructor
   constructor() {
      _disableInitializers();
   }

   /**
    * @notice Initialize the contract (replaces constructor)
    * @param _operator Operator for the contract
    * @param _upgrader Upgrader address for the contract
    */
   function initialize(address _operator, address _upgrader) public initializer {
      __ZkVerifyAggregation_init(_operator, _upgrader);
   }

   /**
    * @notice Initialize the contract (replaces constructor)
    * @param _operator Operator for the contract
    * @param _upgrader Upgrader address for the contract
    */
   function __ZkVerifyAggregation_init(address _operator, address _upgrader) internal onlyInitializing {
      __AccessControl_init();
      __UUPSUpgradeable_init();

      _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); // it is used as owner
      _grantRole(OPERATOR, _operator);
      _grantRole(UPGRADER_ROLE, _upgrader);
   }

   /**
    * @notice Submit Aggregation
    * @param _domainId the id of the domain
    * @param _aggregationId the id of the aggregation from the NewHorizen Relayer
    * @param _proofsAggregation aggregation of a set of proofs
    * @dev caller must have the OPERATOR role, admin can add caller via AccessControl.grantRole()
    */
   function submitAggregation(
      uint256 _domainId,
      uint256 _aggregationId,
      bytes32 _proofsAggregation
   ) external onlyRole(OPERATOR) {
      _registerAggregation(_domainId, _aggregationId, _proofsAggregation);
   }

   /**
    * @notice Submit a Batch of aggregations, for a given domain Id, useful if a relayer needs to catch up.
    * @param _domainId id of domain
    * @param _aggregationIds ids of aggregations from the NewHorizen Relayer
    * @param _proofsAggregations a set of proofs
    * @dev caller must have the OPERATOR role, admin can add caller via AccessControl.grantRole()
    */
   function submitAggregationBatchByDomainId(
      uint256 _domainId,
      uint256[] calldata _aggregationIds,
      bytes32[] calldata _proofsAggregations
   ) external onlyRole(OPERATOR) {

      if(_aggregationIds.length != _proofsAggregations.length) {
         revert InvalidBatchCounts();
      }

      for (uint256 i; i < _aggregationIds.length;) {
         _registerAggregation(_domainId, _aggregationIds[i], _proofsAggregations[i]);
         unchecked {
            ++i;
         }
      }
   }

   /**
    * @notice Function that allows the contract to be upgraded
    * @dev Only accounts with the UPGRADER_ROLE can call this function
    */
   function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) {}
}

// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

import "@polytope-labs/ismp-solidity/interfaces/IIsmpModule.sol";
import "@polytope-labs/ismp-solidity/interfaces/IIsmpHost.sol";
import "@polytope-labs/ismp-solidity/interfaces/Message.sol";
import "@polytope-labs/ismp-solidity/interfaces/IDispatcher.sol";
import "./IsmpGuest.sol";
import "./abstract/ZkVerifyAggregationBase.sol";
import {Bytes} from "@polytope-labs/solidity-merkle-trees/src/trie/Bytes.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

/**
 * @title ZkVerifyAggregationIsmp Contract
 * @notice It allows receiving (from Hyperbridge), persisting and verifying aggregation proofs coming from zkVerify chain.
 */
contract ZkVerifyAggregationIsmp is Initializable, AccessControlUpgradeable, UUPSUpgradeable, IsmpGuest, BaseIsmpModule, ZkVerifyAggregationBase {

    using Bytes for bytes;

    /// @notice State machine for source request
    bytes public constant STATE_MACHINE = bytes("SUBSTRATE-zkv_");

    // @notice Action is unauthorized
    error UnauthorizedAction();

    /// @dev Role that allows upgrading the implementation
    bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /**
     * @notice Initialize the contract (replaces constructor)
     * @param _ismpHost Ismp host contract address
     * @param _upgrader Upgrader address for the contract
     */
    function initialize(address _ismpHost, address _upgrader) public initializer {
        __ZkVerifyAggregationIsmp_init(_ismpHost, _upgrader);
    }

    /**
     * @notice Initialize the ISMP base
     * @param _ismpHost Ismp host contract address
     * @param _upgrader Upgrader address for the contract
     */
    function __ZkVerifyAggregationIsmp_init(address _ismpHost, address _upgrader) internal onlyInitializing {
        __AccessControl_init();
        __UUPSUpgradeable_init();
        __IsmpGuest_init(_ismpHost);

        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(UPGRADER_ROLE, _upgrader);
    }

    function host() public view override returns (address) {
        return getHost();
    }

    /**
     * @notice Receive hyperbridge message containing an aggregation
     * @param incoming request from hyperbridge
     * @dev caller must be host address or risk critical vulnerabilies from unauthorized calls to this method by malicious actors.
     */
    function onAccept(IncomingPostRequest memory incoming) external override onlyHost {

        PostRequest memory request = incoming.request;
        if (!request.source.equals(STATE_MACHINE)) revert UnauthorizedAction();

        (uint256 _domainId, uint256 _aggregationId, bytes32 _proofsAggregation) = abi.decode(request.body, (uint256, uint256, bytes32));

        _registerAggregation(_domainId, _aggregationId, _proofsAggregation);
    }

    /**
     * @notice Function that allows the contract to be upgraded
     * @dev Only accounts with the UPGRADER_ROLE can call this function
     */
    function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) {}
}

Settings
{
  "evmVersion": "paris",
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"IndexOutOfBounds","type":"error"},{"inputs":[],"name":"InvalidBatchCounts","type":"error"},{"inputs":[],"name":"UnauthorizedAction","type":"error"},{"inputs":[],"name":"UnauthorizedCall","type":"error"},{"inputs":[],"name":"UnexpectedCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_domainId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_aggregationId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"_proofsAggregation","type":"bytes32"}],"name":"AggregationPosted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATE_MACHINE","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHost","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"host","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_ismpHost","type":"address"},{"internalType":"address","name":"_upgrader","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes","name":"source","type":"bytes"},{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"from","type":"bytes"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"bytes","name":"body","type":"bytes"}],"internalType":"struct PostRequest","name":"request","type":"tuple"},{"internalType":"address","name":"relayer","type":"address"}],"internalType":"struct IncomingPostRequest","name":"incoming","type":"tuple"}],"name":"onAccept","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"bytes","name":"source","type":"bytes"},{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"bytes[]","name":"keys","type":"bytes[]"},{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes","name":"context","type":"bytes"}],"internalType":"struct GetRequest","name":"request","type":"tuple"},{"components":[{"internalType":"bytes","name":"key","type":"bytes"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct StorageValue[]","name":"values","type":"tuple[]"}],"internalType":"struct GetResponse","name":"response","type":"tuple"},{"internalType":"address","name":"relayer","type":"address"}],"internalType":"struct IncomingGetResponse","name":"","type":"tuple"}],"name":"onGetResponse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"source","type":"bytes"},{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"bytes[]","name":"keys","type":"bytes[]"},{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes","name":"context","type":"bytes"}],"internalType":"struct GetRequest","name":"","type":"tuple"}],"name":"onGetTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"source","type":"bytes"},{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"from","type":"bytes"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"bytes","name":"body","type":"bytes"}],"internalType":"struct PostRequest","name":"","type":"tuple"}],"name":"onPostRequestTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"bytes","name":"source","type":"bytes"},{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"from","type":"bytes"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"bytes","name":"body","type":"bytes"}],"internalType":"struct PostRequest","name":"request","type":"tuple"},{"internalType":"bytes","name":"response","type":"bytes"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"}],"internalType":"struct PostResponse","name":"response","type":"tuple"},{"internalType":"address","name":"relayer","type":"address"}],"internalType":"struct IncomingPostResponse","name":"","type":"tuple"}],"name":"onPostResponse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes","name":"source","type":"bytes"},{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"from","type":"bytes"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"bytes","name":"body","type":"bytes"}],"internalType":"struct PostRequest","name":"request","type":"tuple"},{"internalType":"bytes","name":"response","type":"bytes"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"}],"internalType":"struct PostResponse","name":"","type":"tuple"}],"name":"onPostResponseTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"proofsAggregations","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"bytes","name":"body","type":"bytes"},{"internalType":"uint64","name":"timeout","type":"uint64"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"address","name":"payer","type":"address"}],"internalType":"struct DispatchPost","name":"request","type":"tuple"}],"name":"quote","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes[]","name":"keys","type":"bytes[]"},{"internalType":"uint64","name":"timeout","type":"uint64"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"bytes","name":"context","type":"bytes"}],"internalType":"struct DispatchGet","name":"request","type":"tuple"}],"name":"quote","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes","name":"source","type":"bytes"},{"internalType":"bytes","name":"dest","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"from","type":"bytes"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"bytes","name":"body","type":"bytes"}],"internalType":"struct PostRequest","name":"request","type":"tuple"},{"internalType":"bytes","name":"response","type":"bytes"},{"internalType":"uint64","name":"timeout","type":"uint64"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"address","name":"payer","type":"address"}],"internalType":"struct DispatchPostResponse","name":"response","type":"tuple"}],"name":"quote","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_domainId","type":"uint256"},{"internalType":"uint256","name":"_aggregationId","type":"uint256"},{"internalType":"bytes32","name":"_proofsAggregation","type":"bytes32"}],"name":"submitAggregation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_domainId","type":"uint256"},{"internalType":"uint256[]","name":"_aggregationIds","type":"uint256[]"},{"internalType":"bytes32[]","name":"_proofsAggregations","type":"bytes32[]"}],"name":"submitAggregationBatchByDomainId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_domainId","type":"uint256"},{"internalType":"uint256","name":"_aggregationId","type":"uint256"},{"internalType":"bytes32","name":"_leaf","type":"bytes32"},{"internalType":"bytes32[]","name":"_merklePath","type":"bytes32[]"},{"internalType":"uint256","name":"_leafCount","type":"uint256"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"verifyProofAggregation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

60a06040523073ffffffffffffffffffffffffffffffffffffffff1660809073ffffffffffffffffffffffffffffffffffffffff168152503480156200004457600080fd5b5062000055620001cb60201b60201c565b6000620000676200029260201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614620001b4578073ffffffffffffffffffffffffffffffffffffffff1663647846a56040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000ea573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200011091906200033d565b73ffffffffffffffffffffffffffffffffffffffff1663095ea7b3827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b81526004016200016c9291906200039b565b6020604051808303816000875af11580156200018c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001b2919062000405565b505b50620001c5620001cb60201b60201c565b6200051b565b600060019054906101000a900460ff16156200021e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200021590620004be565b60405180910390fd5b60ff801660008054906101000a900460ff1660ff161015620002905760ff6000806101000a81548160ff021916908360ff1602179055507f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249860ff604051620002879190620004fe565b60405180910390a15b565b6000620002a4620002a960201b60201c565b905090565b600060fb60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200030582620002d8565b9050919050565b6200031781620002f8565b81146200032357600080fd5b50565b60008151905062000337816200030c565b92915050565b600060208284031215620003565762000355620002d3565b5b6000620003668482850162000326565b91505092915050565b6200037a81620002f8565b82525050565b6000819050919050565b620003958162000380565b82525050565b6000604082019050620003b260008301856200036f565b620003c160208301846200038a565b9392505050565b60008115159050919050565b620003df81620003c8565b8114620003eb57600080fd5b50565b600081519050620003ff81620003d4565b92915050565b6000602082840312156200041e576200041d620002d3565b5b60006200042e84828501620003ee565b91505092915050565b600082825260208201905092915050565b7f496e697469616c697a61626c653a20636f6e747261637420697320696e69746960008201527f616c697a696e6700000000000000000000000000000000000000000000000000602082015250565b6000620004a660278362000437565b9150620004b38262000448565b604082019050919050565b60006020820190508181036000830152620004d98162000497565b9050919050565b600060ff82169050919050565b620004f881620004e0565b82525050565b6000602082019050620005156000830184620004ed565b92915050565b6080516145a26200055360003960008181610b0801528181610b9601528181610d5301528181610de10152610e9101526145a26000f3fe6080604052600436106101c25760003560e01c8063983d2737116100f7578063d0fff36611610095578063f3aff07511610064578063f3aff07514610663578063f437bc591461068c578063f72c0d8b146106b7578063fc679aef146106e2576101c2565b8063d0fff366146105ab578063d547741f146105d4578063da9b506e146105fd578063dd92a31614610626576101c2565b8063b2a01bf5116100d1578063b2a01bf5146104f3578063bc0dd4471461051c578063bca96c3914610545578063c0c53b8b14610582576101c2565b8063983d273714610460578063a217fddf1461048b578063a78f9e36146104b6576101c2565b806336568abe1161016457806344ab20f81161013e57806344ab20f8146103b35780634f1ef286146103dc57806352d1902d146103f857806391d1485414610423576101c2565b806336568abe146103245780633659cfe61461034d5780634264b0dc14610376576101c2565b8063108bc1dd116101a0578063108bc1dd1461025657806320bc442514610293578063248a9ca3146102be5780632f2ff15d146102fb576101c2565b806301ffc9a7146101c75780630bc37bab146102045780630fee32ce1461022d575b600080fd5b3480156101d357600080fd5b506101ee60048036038101906101e9919061250b565b61070d565b6040516101fb9190612553565b60405180910390f35b34801561021057600080fd5b5061022b600480360381019061022691906128da565b610787565b005b34801561023957600080fd5b50610254600480360381019061024f91906129ed565b610825565b005b34801561026257600080fd5b5061027d60048036038101906102789190612b60565b610951565b60405161028a9190612bb8565b60405180910390f35b34801561029f57600080fd5b506102a8610a18565b6040516102b59190612be2565b60405180910390f35b3480156102ca57600080fd5b506102e560048036038101906102e09190612c33565b610a42565b6040516102f29190612c6f565b60405180910390f35b34801561030757600080fd5b50610322600480360381019061031d9190612c8a565b610a62565b005b34801561033057600080fd5b5061034b60048036038101906103469190612c8a565b610a83565b005b34801561035957600080fd5b50610374600480360381019061036f9190612cca565b610b06565b005b34801561038257600080fd5b5061039d60048036038101906103989190612cf7565b610c8e565b6040516103aa9190612c6f565b60405180910390f35b3480156103bf57600080fd5b506103da60048036038101906103d591906131b4565b610cb3565b005b6103f660048036038101906103f191906131fd565b610d51565b005b34801561040457600080fd5b5061040d610e8d565b60405161041a9190612c6f565b60405180910390f35b34801561042f57600080fd5b5061044a60048036038101906104459190612c8a565b610f46565b6040516104579190612553565b60405180910390f35b34801561046c57600080fd5b50610475610fb1565b6040516104829190612c6f565b60405180910390f35b34801561049757600080fd5b506104a0610fd5565b6040516104ad9190612c6f565b60405180910390f35b3480156104c257600080fd5b506104dd60048036038101906104d891906132b4565b610fdc565b6040516104ea9190612553565b60405180910390f35b3480156104ff57600080fd5b5061051a600480360381019061051591906133cf565b611022565b005b34801561052857600080fd5b50610543600480360381019061053e9190613418565b6110c0565b005b34801561055157600080fd5b5061056c60048036038101906105679190613555565b61115e565b6040516105799190612bb8565b60405180910390f35b34801561058e57600080fd5b506105a960048036038101906105a4919061359e565b6112ac565b005b3480156105b757600080fd5b506105d260048036038101906105cd91906135f1565b61145f565b005b3480156105e057600080fd5b506105fb60048036038101906105f69190612c8a565b6114fd565b005b34801561060957600080fd5b50610624600480360381019061061f919061363a565b61151e565b005b34801561063257600080fd5b5061064d60048036038101906106489190613751565b611559565b60405161065a9190612bb8565b60405180910390f35b34801561066f57600080fd5b5061068a600480360381019061068591906137f0565b611624565b005b34801561069857600080fd5b506106a16116ec565b6040516106ae9190612be2565b60405180910390f35b3480156106c357600080fd5b506106cc6116fb565b6040516106d99190612c6f565b60405180910390f35b3480156106ee57600080fd5b506106f761171f565b6040516107049190613904565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610780575061077f82611758565b5b9050919050565b61078f6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107f3576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61082d6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610891576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000816000015190506108e66040518060400160405280600e81526020017f5355425354524154452d7a6b765f00000000000000000000000000000000000081525082600001516117c290919063ffffffff16565b61091c576040517f843800fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060008360c001518060200190518101906109399190613950565b92509250925061094a8383836117fc565b5050505050565b60008082604001515160201161096c5782604001515161096f565b60205b90506109796116ec565b73ffffffffffffffffffffffffffffffffffffffff16634011ec0a84600001516040518263ffffffff1660e01b81526004016109b59190613904565b602060405180830381865afa1580156109d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f691906139a3565b81610a0191906139ff565b8360800151610a109190613a41565b915050919050565b600060fb60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600060656000838152602001908152602001600020600101549050919050565b610a6b82610a42565b610a7481611859565b610a7e838361186d565b505050565b610a8b61194e565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610af8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aef90613af8565b60405180910390fd5b610b028282611956565b5050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1603610b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8b90613b8a565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610bd3611a38565b73ffffffffffffffffffffffffffffffffffffffff1614610c29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2090613c1c565b60405180910390fd5b610c3281611a8f565b610c8b81600067ffffffffffffffff811115610c5157610c50612584565b5b6040519080825280601f01601f191660200182016040528015610c835781602001600182028036833780820191505090505b506000611abd565b50565b60fc602052816000526040600020602052806000526040600020600091509150505481565b610cbb6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d1f576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1603610ddf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd690613b8a565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610e1e611a38565b73ffffffffffffffffffffffffffffffffffffffff1614610e74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6b90613c1c565b60405180910390fd5b610e7d82611a8f565b610e8982826001611abd565b5050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614610f1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1490613cae565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905090565b60006065600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c81565b6000801b81565b60008060fc60008a8152602001908152602001600020600089815260200190815260200160002054905061101481878787878c611c2b565b915050979650505050505050565b61102a6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108e576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110c86116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461112c576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806111696116ec565b73ffffffffffffffffffffffffffffffffffffffff16634011ec0a61118c6116ec565b73ffffffffffffffffffffffffffffffffffffffff1663f437bc596040518163ffffffff1660e01b8152600401600060405180830381865afa1580156111d6573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906111ff9190613d3e565b6040518263ffffffff1660e01b815260040161121b9190613904565b602060405180830381865afa158015611238573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125c91906139a3565b9050600081602061126d91906139ff565b905060008460a00151518361128291906139ff565b85608001516112919190613a41565b90508082116112a057806112a2565b815b9350505050919050565b60008060019054906101000a900460ff161590508080156112dd5750600160008054906101000a900460ff1660ff16105b8061130a57506112ec30611da9565b1580156113095750600160008054906101000a900460ff1660ff16145b5b611349576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134090613df9565b60405180910390fd5b60016000806101000a81548160ff021916908360ff1602179055508015611386576001600060016101000a81548160ff0219169083151502179055505b61138e611dcc565b611396611e1d565b61139f83611e6e565b6113ac6000801b3361186d565b6113d67f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c8561186d565b6114007f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e38361186d565b80156114595760008060016101000a81548160ff0219169083151502179055507f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249860016040516114509190613e6b565b60405180910390a15b50505050565b6114676116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114cb576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61150682610a42565b61150f81611859565b6115198383611956565b505050565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c61154881611859565b6115538484846117fc565b50505050565b60008082602001515160201161157457826020015151611577565b60205b90506115816116ec565b73ffffffffffffffffffffffffffffffffffffffff16634011ec0a8460000151600001516040518263ffffffff1660e01b81526004016115c19190613904565b602060405180830381865afa1580156115de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160291906139a3565b8161160d91906139ff565b836060015161161c9190613a41565b915050919050565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c61164e81611859565b82829050858590501461168d576040517f73d99d3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b858590508110156116e3576116d8878787848181106116b2576116b1613e86565b5b905060200201358686858181106116cc576116cb613e86565b5b905060200201356117fc565b806001019050611690565b50505050505050565b60006116f6610a18565b905090565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b6040518060400160405280600e81526020017f5355425354524154452d7a6b765f00000000000000000000000000000000000081525081565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600081518351146117d657600090506117f6565b6000806020850191506020840190506117f182828751611f01565b925050505b92915050565b8060fc60008581526020019081526020016000206000848152602001908152602001600020819055508082847f431e1446261f5ed64f6fcd5c8a75fe76dcc7c2c207555eeb6cf27749e78ca22660405160405180910390a4505050565b61186a8161186561194e565b611f13565b50565b6118778282610f46565b61194a5760016065600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506118ef61194e565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600033905090565b6119608282610f46565b15611a345760006065600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506119d961194e565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b6000611a667f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b611f98565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e3611ab981611859565b5050565b611ae97f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd914360001b611fa2565b60000160009054906101000a900460ff1615611b0d57611b0883611fac565b611c26565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611b7557506040513d601f19601f82011682018060405250810190611b729190613eb5565b60015b611bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bab90613f54565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b8114611c19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c1090613fe6565b60405180910390fd5b50611c25838383612065565b5b505050565b6000838310611c66576040517f4e23d03500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600082604051602001611c799190614027565b60405160208183030381529060405280519060200120905060008490506000869050600089899050905060005b81811015611d955760008b8b83818110611cc357611cc2613e86565b5b9050602002013590506001600286611cdb9190614071565b1480611cf2575083600186611cf09190613a41565b145b15611d27578086604051602001611d0a9291906140a2565b604051602081830303815290604052805190602001209550611d53565b8581604051602001611d3a9291906140a2565b6040516020818303038152906040528051906020012095505b600285611d6091906140ce565b945060016002600186611d7391906140ff565b611d7d91906140ce565b611d879190613a41565b935081600101915050611ca6565b508a84149450505050509695505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600060019054906101000a900460ff16611e1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e12906141a5565b60405180910390fd5b565b600060019054906101000a900460ff16611e6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e63906141a5565b60405180910390fd5b565b600060019054906101000a900460ff16611ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb4906141a5565b60405180910390fd5b8060fb60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008183208285201490509392505050565b611f1d8282610f46565b611f9457611f2a81612091565b611f388360001c60206120be565b604051602001611f499291906142a4565b6040516020818303038152906040526040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f8b9190614317565b60405180910390fd5b5050565b6000819050919050565b6000819050919050565b611fb581611da9565b611ff4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611feb906143ab565b60405180910390fd5b806120217f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b611f98565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61206e836122fa565b60008251118061207b5750805b1561208c5761208a8383612349565b505b505050565b60606120b78273ffffffffffffffffffffffffffffffffffffffff16601460ff166120be565b9050919050565b6060600060028360026120d191906139ff565b6120db9190613a41565b67ffffffffffffffff8111156120f4576120f3612584565b5b6040519080825280601f01601f1916602001820160405280156121265781602001600182028036833780820191505090505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061215e5761215d613e86565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106121c2576121c1613e86565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000600184600261220291906139ff565b61220c9190613a41565b90505b60018111156122ac577f3031323334353637383961626364656600000000000000000000000000000000600f86166010811061224e5761224d613e86565b5b1a60f81b82828151811061226557612264613e86565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c9450806122a5906143cb565b905061220f565b50600084146122f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122e790614440565b60405180910390fd5b8091505092915050565b61230381611fac565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b606061235483611da9565b612393576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161238a906144d2565b60405180910390fd5b6000808473ffffffffffffffffffffffffffffffffffffffff16846040516123bb919061452e565b600060405180830381855af49150503d80600081146123f6576040519150601f19603f3d011682016040523d82523d6000602084013e6123fb565b606091505b509150915061242382826040518060600160405280602781526020016145466027913961242d565b9250505092915050565b6060831561243d57829050612448565b612447838361244f565b5b9392505050565b6000825111156124625781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124969190614317565b60405180910390fd5b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6124e8816124b3565b81146124f357600080fd5b50565b600081359050612505816124df565b92915050565b600060208284031215612521576125206124a9565b5b600061252f848285016124f6565b91505092915050565b60008115159050919050565b61254d81612538565b82525050565b60006020820190506125686000830184612544565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6125bc82612573565b810181811067ffffffffffffffff821117156125db576125da612584565b5b80604052505050565b60006125ee61249f565b90506125fa82826125b3565b919050565b600080fd5b600080fd5b600080fd5b600067ffffffffffffffff82111561262957612628612584565b5b61263282612573565b9050602081019050919050565b82818337600083830152505050565b600061266161265c8461260e565b6125e4565b90508281526020810184848401111561267d5761267c612609565b5b61268884828561263f565b509392505050565b600082601f8301126126a5576126a4612604565b5b81356126b584826020860161264e565b91505092915050565b600067ffffffffffffffff82169050919050565b6126db816126be565b81146126e657600080fd5b50565b6000813590506126f8816126d2565b92915050565b600060e082840312156127145761271361256e565b5b61271e60e06125e4565b9050600082013567ffffffffffffffff81111561273e5761273d6125ff565b5b61274a84828501612690565b600083015250602082013567ffffffffffffffff81111561276e5761276d6125ff565b5b61277a84828501612690565b602083015250604061278e848285016126e9565b604083015250606082013567ffffffffffffffff8111156127b2576127b16125ff565b5b6127be84828501612690565b606083015250608082013567ffffffffffffffff8111156127e2576127e16125ff565b5b6127ee84828501612690565b60808301525060a0612802848285016126e9565b60a08301525060c082013567ffffffffffffffff811115612826576128256125ff565b5b61283284828501612690565b60c08301525092915050565b6000606082840312156128545761285361256e565b5b61285e60606125e4565b9050600082013567ffffffffffffffff81111561287e5761287d6125ff565b5b61288a848285016126fe565b600083015250602082013567ffffffffffffffff8111156128ae576128ad6125ff565b5b6128ba84828501612690565b60208301525060406128ce848285016126e9565b60408301525092915050565b6000602082840312156128f0576128ef6124a9565b5b600082013567ffffffffffffffff81111561290e5761290d6124ae565b5b61291a8482850161283e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061294e82612923565b9050919050565b61295e81612943565b811461296957600080fd5b50565b60008135905061297b81612955565b92915050565b6000604082840312156129975761299661256e565b5b6129a160406125e4565b9050600082013567ffffffffffffffff8111156129c1576129c06125ff565b5b6129cd848285016126fe565b60008301525060206129e18482850161296c565b60208301525092915050565b600060208284031215612a0357612a026124a9565b5b600082013567ffffffffffffffff811115612a2157612a206124ae565b5b612a2d84828501612981565b91505092915050565b6000819050919050565b612a4981612a36565b8114612a5457600080fd5b50565b600081359050612a6681612a40565b92915050565b600060c08284031215612a8257612a8161256e565b5b612a8c60c06125e4565b9050600082013567ffffffffffffffff811115612aac57612aab6125ff565b5b612ab884828501612690565b600083015250602082013567ffffffffffffffff811115612adc57612adb6125ff565b5b612ae884828501612690565b602083015250604082013567ffffffffffffffff811115612b0c57612b0b6125ff565b5b612b1884828501612690565b6040830152506060612b2c848285016126e9565b6060830152506080612b4084828501612a57565b60808301525060a0612b548482850161296c565b60a08301525092915050565b600060208284031215612b7657612b756124a9565b5b600082013567ffffffffffffffff811115612b9457612b936124ae565b5b612ba084828501612a6c565b91505092915050565b612bb281612a36565b82525050565b6000602082019050612bcd6000830184612ba9565b92915050565b612bdc81612943565b82525050565b6000602082019050612bf76000830184612bd3565b92915050565b6000819050919050565b612c1081612bfd565b8114612c1b57600080fd5b50565b600081359050612c2d81612c07565b92915050565b600060208284031215612c4957612c486124a9565b5b6000612c5784828501612c1e565b91505092915050565b612c6981612bfd565b82525050565b6000602082019050612c846000830184612c60565b92915050565b60008060408385031215612ca157612ca06124a9565b5b6000612caf85828601612c1e565b9250506020612cc08582860161296c565b9150509250929050565b600060208284031215612ce057612cdf6124a9565b5b6000612cee8482850161296c565b91505092915050565b60008060408385031215612d0e57612d0d6124a9565b5b6000612d1c85828601612a57565b9250506020612d2d85828601612a57565b9150509250929050565b600067ffffffffffffffff821115612d5257612d51612584565b5b602082029050602081019050919050565b600080fd5b6000612d7b612d7684612d37565b6125e4565b90508083825260208201905060208402830185811115612d9e57612d9d612d63565b5b835b81811015612de557803567ffffffffffffffff811115612dc357612dc2612604565b5b808601612dd08982612690565b85526020850194505050602081019050612da0565b5050509392505050565b600082601f830112612e0457612e03612604565b5b8135612e14848260208601612d68565b91505092915050565b60006101008284031215612e3457612e3361256e565b5b612e3f6101006125e4565b9050600082013567ffffffffffffffff811115612e5f57612e5e6125ff565b5b612e6b84828501612690565b600083015250602082013567ffffffffffffffff811115612e8f57612e8e6125ff565b5b612e9b84828501612690565b6020830152506040612eaf848285016126e9565b6040830152506060612ec38482850161296c565b6060830152506080612ed7848285016126e9565b60808301525060a082013567ffffffffffffffff811115612efb57612efa6125ff565b5b612f0784828501612def565b60a08301525060c0612f1b848285016126e9565b60c08301525060e082013567ffffffffffffffff811115612f3f57612f3e6125ff565b5b612f4b84828501612690565b60e08301525092915050565b600067ffffffffffffffff821115612f7257612f71612584565b5b602082029050602081019050919050565b600060408284031215612f9957612f9861256e565b5b612fa360406125e4565b9050600082013567ffffffffffffffff811115612fc357612fc26125ff565b5b612fcf84828501612690565b600083015250602082013567ffffffffffffffff811115612ff357612ff26125ff565b5b612fff84828501612690565b60208301525092915050565b600061301e61301984612f57565b6125e4565b9050808382526020820190506020840283018581111561304157613040612d63565b5b835b8181101561308857803567ffffffffffffffff81111561306657613065612604565b5b8086016130738982612f83565b85526020850194505050602081019050613043565b5050509392505050565b600082601f8301126130a7576130a6612604565b5b81356130b784826020860161300b565b91505092915050565b6000604082840312156130d6576130d561256e565b5b6130e060406125e4565b9050600082013567ffffffffffffffff811115613100576130ff6125ff565b5b61310c84828501612e1d565b600083015250602082013567ffffffffffffffff8111156131305761312f6125ff565b5b61313c84828501613092565b60208301525092915050565b60006040828403121561315e5761315d61256e565b5b61316860406125e4565b9050600082013567ffffffffffffffff811115613188576131876125ff565b5b613194848285016130c0565b60008301525060206131a88482850161296c565b60208301525092915050565b6000602082840312156131ca576131c96124a9565b5b600082013567ffffffffffffffff8111156131e8576131e76124ae565b5b6131f484828501613148565b91505092915050565b60008060408385031215613214576132136124a9565b5b60006132228582860161296c565b925050602083013567ffffffffffffffff811115613243576132426124ae565b5b61324f85828601612690565b9150509250929050565b600080fd5b60008083601f84011261327457613273612604565b5b8235905067ffffffffffffffff81111561329157613290613259565b5b6020830191508360208202830111156132ad576132ac612d63565b5b9250929050565b600080600080600080600060c0888a0312156132d3576132d26124a9565b5b60006132e18a828b01612a57565b97505060206132f28a828b01612a57565b96505060406133038a828b01612c1e565b955050606088013567ffffffffffffffff811115613324576133236124ae565b5b6133308a828b0161325e565b945094505060806133438a828b01612a57565b92505060a06133548a828b01612a57565b91505092959891949750929550565b6000604082840312156133795761337861256e565b5b61338360406125e4565b9050600082013567ffffffffffffffff8111156133a3576133a26125ff565b5b6133af8482850161283e565b60008301525060206133c38482850161296c565b60208301525092915050565b6000602082840312156133e5576133e46124a9565b5b600082013567ffffffffffffffff811115613403576134026124ae565b5b61340f84828501613363565b91505092915050565b60006020828403121561342e5761342d6124a9565b5b600082013567ffffffffffffffff81111561344c5761344b6124ae565b5b613458848285016126fe565b91505092915050565b600060c082840312156134775761347661256e565b5b61348160c06125e4565b9050600082013567ffffffffffffffff8111156134a1576134a06125ff565b5b6134ad84828501612690565b60008301525060206134c1848285016126e9565b602083015250604082013567ffffffffffffffff8111156134e5576134e46125ff565b5b6134f184828501612def565b6040830152506060613505848285016126e9565b606083015250608061351984828501612a57565b60808301525060a082013567ffffffffffffffff81111561353d5761353c6125ff565b5b61354984828501612690565b60a08301525092915050565b60006020828403121561356b5761356a6124a9565b5b600082013567ffffffffffffffff811115613589576135886124ae565b5b61359584828501613461565b91505092915050565b6000806000606084860312156135b7576135b66124a9565b5b60006135c58682870161296c565b93505060206135d68682870161296c565b92505060406135e78682870161296c565b9150509250925092565b600060208284031215613607576136066124a9565b5b600082013567ffffffffffffffff811115613625576136246124ae565b5b61363184828501612e1d565b91505092915050565b600080600060608486031215613653576136526124a9565b5b600061366186828701612a57565b935050602061367286828701612a57565b925050604061368386828701612c1e565b9150509250925092565b600060a082840312156136a3576136a261256e565b5b6136ad60a06125e4565b9050600082013567ffffffffffffffff8111156136cd576136cc6125ff565b5b6136d9848285016126fe565b600083015250602082013567ffffffffffffffff8111156136fd576136fc6125ff565b5b61370984828501612690565b602083015250604061371d848285016126e9565b604083015250606061373184828501612a57565b60608301525060806137458482850161296c565b60808301525092915050565b600060208284031215613767576137666124a9565b5b600082013567ffffffffffffffff811115613785576137846124ae565b5b6137918482850161368d565b91505092915050565b60008083601f8401126137b0576137af612604565b5b8235905067ffffffffffffffff8111156137cd576137cc613259565b5b6020830191508360208202830111156137e9576137e8612d63565b5b9250929050565b60008060008060006060868803121561380c5761380b6124a9565b5b600061381a88828901612a57565b955050602086013567ffffffffffffffff81111561383b5761383a6124ae565b5b6138478882890161379a565b9450945050604086013567ffffffffffffffff81111561386a576138696124ae565b5b6138768882890161325e565b92509250509295509295909350565b600081519050919050565b600082825260208201905092915050565b60005b838110156138bf5780820151818401526020810190506138a4565b60008484015250505050565b60006138d682613885565b6138e08185613890565b93506138f08185602086016138a1565b6138f981612573565b840191505092915050565b6000602082019050818103600083015261391e81846138cb565b905092915050565b60008151905061393581612a40565b92915050565b60008151905061394a81612c07565b92915050565b600080600060608486031215613969576139686124a9565b5b600061397786828701613926565b935050602061398886828701613926565b92505060406139998682870161393b565b9150509250925092565b6000602082840312156139b9576139b86124a9565b5b60006139c784828501613926565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613a0a82612a36565b9150613a1583612a36565b9250828202613a2381612a36565b91508282048414831517613a3a57613a396139d0565b5b5092915050565b6000613a4c82612a36565b9150613a5783612a36565b9250828201905080821115613a6f57613a6e6139d0565b5b92915050565b600082825260208201905092915050565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b6000613ae2602f83613a75565b9150613aed82613a86565b604082019050919050565b60006020820190508181036000830152613b1181613ad5565b9050919050565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f64656c656761746563616c6c0000000000000000000000000000000000000000602082015250565b6000613b74602c83613a75565b9150613b7f82613b18565b604082019050919050565b60006020820190508181036000830152613ba381613b67565b9050919050565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f6163746976652070726f78790000000000000000000000000000000000000000602082015250565b6000613c06602c83613a75565b9150613c1182613baa565b604082019050919050565b60006020820190508181036000830152613c3581613bf9565b9050919050565b7f555550535570677261646561626c653a206d757374206e6f742062652063616c60008201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000602082015250565b6000613c98603883613a75565b9150613ca382613c3c565b604082019050919050565b60006020820190508181036000830152613cc781613c8b565b9050919050565b6000613ce1613cdc8461260e565b6125e4565b905082815260208101848484011115613cfd57613cfc612609565b5b613d088482856138a1565b509392505050565b600082601f830112613d2557613d24612604565b5b8151613d35848260208601613cce565b91505092915050565b600060208284031215613d5457613d536124a9565b5b600082015167ffffffffffffffff811115613d7257613d716124ae565b5b613d7e84828501613d10565b91505092915050565b7f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201527f647920696e697469616c697a6564000000000000000000000000000000000000602082015250565b6000613de3602e83613a75565b9150613dee82613d87565b604082019050919050565b60006020820190508181036000830152613e1281613dd6565b9050919050565b6000819050919050565b600060ff82169050919050565b6000819050919050565b6000613e55613e50613e4b84613e19565b613e30565b613e23565b9050919050565b613e6581613e3a565b82525050565b6000602082019050613e806000830184613e5c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613ecb57613eca6124a9565b5b6000613ed98482850161393b565b91505092915050565b7f45524331393637557067726164653a206e657720696d706c656d656e7461746960008201527f6f6e206973206e6f742055555053000000000000000000000000000000000000602082015250565b6000613f3e602e83613a75565b9150613f4982613ee2565b604082019050919050565b60006020820190508181036000830152613f6d81613f31565b9050919050565b7f45524331393637557067726164653a20756e737570706f727465642070726f7860008201527f6961626c65555549440000000000000000000000000000000000000000000000602082015250565b6000613fd0602983613a75565b9150613fdb82613f74565b604082019050919050565b60006020820190508181036000830152613fff81613fc3565b9050919050565b6000819050919050565b61402161401c82612bfd565b614006565b82525050565b60006140338284614010565b60208201915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061407c82612a36565b915061408783612a36565b92508261409757614096614042565b5b828206905092915050565b60006140ae8285614010565b6020820191506140be8284614010565b6020820191508190509392505050565b60006140d982612a36565b91506140e483612a36565b9250826140f4576140f3614042565b5b828204905092915050565b600061410a82612a36565b915061411583612a36565b925082820390508181111561412d5761412c6139d0565b5b92915050565b7f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960008201527f6e697469616c697a696e67000000000000000000000000000000000000000000602082015250565b600061418f602b83613a75565b915061419a82614133565b604082019050919050565b600060208201905081810360008301526141be81614182565b9050919050565b600081905092915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b60006142066017836141c5565b9150614211826141d0565b601782019050919050565b600081519050919050565b60006142328261421c565b61423c81856141c5565b935061424c8185602086016138a1565b80840191505092915050565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b600061428e6011836141c5565b915061429982614258565b601182019050919050565b60006142af826141f9565b91506142bb8285614227565b91506142c682614281565b91506142d28284614227565b91508190509392505050565b60006142e98261421c565b6142f38185613a75565b93506143038185602086016138a1565b61430c81612573565b840191505092915050565b6000602082019050818103600083015261433181846142de565b905092915050565b7f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60008201527f6f74206120636f6e747261637400000000000000000000000000000000000000602082015250565b6000614395602d83613a75565b91506143a082614339565b604082019050919050565b600060208201905081810360008301526143c481614388565b9050919050565b60006143d682612a36565b9150600082036143e9576143e86139d0565b5b600182039050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b600061442a602083613a75565b9150614435826143f4565b602082019050919050565b600060208201905081810360008301526144598161441d565b9050919050565b7f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60008201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b60006144bc602683613a75565b91506144c782614460565b604082019050919050565b600060208201905081810360008301526144eb816144af565b9050919050565b600081905092915050565b600061450882613885565b61451281856144f2565b93506145228185602086016138a1565b80840191505092915050565b600061453a82846144fd565b91508190509291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122014b7f655743616a457a79f64363660819009eedfff0ddd4389f3e9db93c4445664736f6c63430008140033

Deployed Bytecode

0x6080604052600436106101c25760003560e01c8063983d2737116100f7578063d0fff36611610095578063f3aff07511610064578063f3aff07514610663578063f437bc591461068c578063f72c0d8b146106b7578063fc679aef146106e2576101c2565b8063d0fff366146105ab578063d547741f146105d4578063da9b506e146105fd578063dd92a31614610626576101c2565b8063b2a01bf5116100d1578063b2a01bf5146104f3578063bc0dd4471461051c578063bca96c3914610545578063c0c53b8b14610582576101c2565b8063983d273714610460578063a217fddf1461048b578063a78f9e36146104b6576101c2565b806336568abe1161016457806344ab20f81161013e57806344ab20f8146103b35780634f1ef286146103dc57806352d1902d146103f857806391d1485414610423576101c2565b806336568abe146103245780633659cfe61461034d5780634264b0dc14610376576101c2565b8063108bc1dd116101a0578063108bc1dd1461025657806320bc442514610293578063248a9ca3146102be5780632f2ff15d146102fb576101c2565b806301ffc9a7146101c75780630bc37bab146102045780630fee32ce1461022d575b600080fd5b3480156101d357600080fd5b506101ee60048036038101906101e9919061250b565b61070d565b6040516101fb9190612553565b60405180910390f35b34801561021057600080fd5b5061022b600480360381019061022691906128da565b610787565b005b34801561023957600080fd5b50610254600480360381019061024f91906129ed565b610825565b005b34801561026257600080fd5b5061027d60048036038101906102789190612b60565b610951565b60405161028a9190612bb8565b60405180910390f35b34801561029f57600080fd5b506102a8610a18565b6040516102b59190612be2565b60405180910390f35b3480156102ca57600080fd5b506102e560048036038101906102e09190612c33565b610a42565b6040516102f29190612c6f565b60405180910390f35b34801561030757600080fd5b50610322600480360381019061031d9190612c8a565b610a62565b005b34801561033057600080fd5b5061034b60048036038101906103469190612c8a565b610a83565b005b34801561035957600080fd5b50610374600480360381019061036f9190612cca565b610b06565b005b34801561038257600080fd5b5061039d60048036038101906103989190612cf7565b610c8e565b6040516103aa9190612c6f565b60405180910390f35b3480156103bf57600080fd5b506103da60048036038101906103d591906131b4565b610cb3565b005b6103f660048036038101906103f191906131fd565b610d51565b005b34801561040457600080fd5b5061040d610e8d565b60405161041a9190612c6f565b60405180910390f35b34801561042f57600080fd5b5061044a60048036038101906104459190612c8a565b610f46565b6040516104579190612553565b60405180910390f35b34801561046c57600080fd5b50610475610fb1565b6040516104829190612c6f565b60405180910390f35b34801561049757600080fd5b506104a0610fd5565b6040516104ad9190612c6f565b60405180910390f35b3480156104c257600080fd5b506104dd60048036038101906104d891906132b4565b610fdc565b6040516104ea9190612553565b60405180910390f35b3480156104ff57600080fd5b5061051a600480360381019061051591906133cf565b611022565b005b34801561052857600080fd5b50610543600480360381019061053e9190613418565b6110c0565b005b34801561055157600080fd5b5061056c60048036038101906105679190613555565b61115e565b6040516105799190612bb8565b60405180910390f35b34801561058e57600080fd5b506105a960048036038101906105a4919061359e565b6112ac565b005b3480156105b757600080fd5b506105d260048036038101906105cd91906135f1565b61145f565b005b3480156105e057600080fd5b506105fb60048036038101906105f69190612c8a565b6114fd565b005b34801561060957600080fd5b50610624600480360381019061061f919061363a565b61151e565b005b34801561063257600080fd5b5061064d60048036038101906106489190613751565b611559565b60405161065a9190612bb8565b60405180910390f35b34801561066f57600080fd5b5061068a600480360381019061068591906137f0565b611624565b005b34801561069857600080fd5b506106a16116ec565b6040516106ae9190612be2565b60405180910390f35b3480156106c357600080fd5b506106cc6116fb565b6040516106d99190612c6f565b60405180910390f35b3480156106ee57600080fd5b506106f761171f565b6040516107049190613904565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610780575061077f82611758565b5b9050919050565b61078f6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107f3576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61082d6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610891576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000816000015190506108e66040518060400160405280600e81526020017f5355425354524154452d7a6b765f00000000000000000000000000000000000081525082600001516117c290919063ffffffff16565b61091c576040517f843800fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060008360c001518060200190518101906109399190613950565b92509250925061094a8383836117fc565b5050505050565b60008082604001515160201161096c5782604001515161096f565b60205b90506109796116ec565b73ffffffffffffffffffffffffffffffffffffffff16634011ec0a84600001516040518263ffffffff1660e01b81526004016109b59190613904565b602060405180830381865afa1580156109d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f691906139a3565b81610a0191906139ff565b8360800151610a109190613a41565b915050919050565b600060fb60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600060656000838152602001908152602001600020600101549050919050565b610a6b82610a42565b610a7481611859565b610a7e838361186d565b505050565b610a8b61194e565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610af8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aef90613af8565b60405180910390fd5b610b028282611956565b5050565b7f0000000000000000000000005a3c35ccc5c05fdefe5ecafc15f4b1ac8ef7148173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1603610b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8b90613b8a565b60405180910390fd5b7f0000000000000000000000005a3c35ccc5c05fdefe5ecafc15f4b1ac8ef7148173ffffffffffffffffffffffffffffffffffffffff16610bd3611a38565b73ffffffffffffffffffffffffffffffffffffffff1614610c29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2090613c1c565b60405180910390fd5b610c3281611a8f565b610c8b81600067ffffffffffffffff811115610c5157610c50612584565b5b6040519080825280601f01601f191660200182016040528015610c835781602001600182028036833780820191505090505b506000611abd565b50565b60fc602052816000526040600020602052806000526040600020600091509150505481565b610cbb6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d1f576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000005a3c35ccc5c05fdefe5ecafc15f4b1ac8ef7148173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1603610ddf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd690613b8a565b60405180910390fd5b7f0000000000000000000000005a3c35ccc5c05fdefe5ecafc15f4b1ac8ef7148173ffffffffffffffffffffffffffffffffffffffff16610e1e611a38565b73ffffffffffffffffffffffffffffffffffffffff1614610e74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6b90613c1c565b60405180910390fd5b610e7d82611a8f565b610e8982826001611abd565b5050565b60007f0000000000000000000000005a3c35ccc5c05fdefe5ecafc15f4b1ac8ef7148173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614610f1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1490613cae565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905090565b60006065600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c81565b6000801b81565b60008060fc60008a8152602001908152602001600020600089815260200190815260200160002054905061101481878787878c611c2b565b915050979650505050505050565b61102a6116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108e576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110c86116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461112c576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806111696116ec565b73ffffffffffffffffffffffffffffffffffffffff16634011ec0a61118c6116ec565b73ffffffffffffffffffffffffffffffffffffffff1663f437bc596040518163ffffffff1660e01b8152600401600060405180830381865afa1580156111d6573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906111ff9190613d3e565b6040518263ffffffff1660e01b815260040161121b9190613904565b602060405180830381865afa158015611238573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125c91906139a3565b9050600081602061126d91906139ff565b905060008460a00151518361128291906139ff565b85608001516112919190613a41565b90508082116112a057806112a2565b815b9350505050919050565b60008060019054906101000a900460ff161590508080156112dd5750600160008054906101000a900460ff1660ff16105b8061130a57506112ec30611da9565b1580156113095750600160008054906101000a900460ff1660ff16145b5b611349576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134090613df9565b60405180910390fd5b60016000806101000a81548160ff021916908360ff1602179055508015611386576001600060016101000a81548160ff0219169083151502179055505b61138e611dcc565b611396611e1d565b61139f83611e6e565b6113ac6000801b3361186d565b6113d67f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c8561186d565b6114007f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e38361186d565b80156114595760008060016101000a81548160ff0219169083151502179055507f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249860016040516114509190613e6b565b60405180910390a15b50505050565b6114676116ec565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114cb576040517f7bf6a16f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f02cbc79f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61150682610a42565b61150f81611859565b6115198383611956565b505050565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c61154881611859565b6115538484846117fc565b50505050565b60008082602001515160201161157457826020015151611577565b60205b90506115816116ec565b73ffffffffffffffffffffffffffffffffffffffff16634011ec0a8460000151600001516040518263ffffffff1660e01b81526004016115c19190613904565b602060405180830381865afa1580156115de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160291906139a3565b8161160d91906139ff565b836060015161161c9190613a41565b915050919050565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c61164e81611859565b82829050858590501461168d576040517f73d99d3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b858590508110156116e3576116d8878787848181106116b2576116b1613e86565b5b905060200201358686858181106116cc576116cb613e86565b5b905060200201356117fc565b806001019050611690565b50505050505050565b60006116f6610a18565b905090565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b6040518060400160405280600e81526020017f5355425354524154452d7a6b765f00000000000000000000000000000000000081525081565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600081518351146117d657600090506117f6565b6000806020850191506020840190506117f182828751611f01565b925050505b92915050565b8060fc60008581526020019081526020016000206000848152602001908152602001600020819055508082847f431e1446261f5ed64f6fcd5c8a75fe76dcc7c2c207555eeb6cf27749e78ca22660405160405180910390a4505050565b61186a8161186561194e565b611f13565b50565b6118778282610f46565b61194a5760016065600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506118ef61194e565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600033905090565b6119608282610f46565b15611a345760006065600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506119d961194e565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b6000611a667f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b611f98565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e3611ab981611859565b5050565b611ae97f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd914360001b611fa2565b60000160009054906101000a900460ff1615611b0d57611b0883611fac565b611c26565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611b7557506040513d601f19601f82011682018060405250810190611b729190613eb5565b60015b611bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bab90613f54565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b8114611c19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c1090613fe6565b60405180910390fd5b50611c25838383612065565b5b505050565b6000838310611c66576040517f4e23d03500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600082604051602001611c799190614027565b60405160208183030381529060405280519060200120905060008490506000869050600089899050905060005b81811015611d955760008b8b83818110611cc357611cc2613e86565b5b9050602002013590506001600286611cdb9190614071565b1480611cf2575083600186611cf09190613a41565b145b15611d27578086604051602001611d0a9291906140a2565b604051602081830303815290604052805190602001209550611d53565b8581604051602001611d3a9291906140a2565b6040516020818303038152906040528051906020012095505b600285611d6091906140ce565b945060016002600186611d7391906140ff565b611d7d91906140ce565b611d879190613a41565b935081600101915050611ca6565b508a84149450505050509695505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600060019054906101000a900460ff16611e1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e12906141a5565b60405180910390fd5b565b600060019054906101000a900460ff16611e6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e63906141a5565b60405180910390fd5b565b600060019054906101000a900460ff16611ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb4906141a5565b60405180910390fd5b8060fb60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008183208285201490509392505050565b611f1d8282610f46565b611f9457611f2a81612091565b611f388360001c60206120be565b604051602001611f499291906142a4565b6040516020818303038152906040526040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f8b9190614317565b60405180910390fd5b5050565b6000819050919050565b6000819050919050565b611fb581611da9565b611ff4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611feb906143ab565b60405180910390fd5b806120217f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b611f98565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61206e836122fa565b60008251118061207b5750805b1561208c5761208a8383612349565b505b505050565b60606120b78273ffffffffffffffffffffffffffffffffffffffff16601460ff166120be565b9050919050565b6060600060028360026120d191906139ff565b6120db9190613a41565b67ffffffffffffffff8111156120f4576120f3612584565b5b6040519080825280601f01601f1916602001820160405280156121265781602001600182028036833780820191505090505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061215e5761215d613e86565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106121c2576121c1613e86565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000600184600261220291906139ff565b61220c9190613a41565b90505b60018111156122ac577f3031323334353637383961626364656600000000000000000000000000000000600f86166010811061224e5761224d613e86565b5b1a60f81b82828151811061226557612264613e86565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c9450806122a5906143cb565b905061220f565b50600084146122f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122e790614440565b60405180910390fd5b8091505092915050565b61230381611fac565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b606061235483611da9565b612393576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161238a906144d2565b60405180910390fd5b6000808473ffffffffffffffffffffffffffffffffffffffff16846040516123bb919061452e565b600060405180830381855af49150503d80600081146123f6576040519150601f19603f3d011682016040523d82523d6000602084013e6123fb565b606091505b509150915061242382826040518060600160405280602781526020016145466027913961242d565b9250505092915050565b6060831561243d57829050612448565b612447838361244f565b5b9392505050565b6000825111156124625781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124969190614317565b60405180910390fd5b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6124e8816124b3565b81146124f357600080fd5b50565b600081359050612505816124df565b92915050565b600060208284031215612521576125206124a9565b5b600061252f848285016124f6565b91505092915050565b60008115159050919050565b61254d81612538565b82525050565b60006020820190506125686000830184612544565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6125bc82612573565b810181811067ffffffffffffffff821117156125db576125da612584565b5b80604052505050565b60006125ee61249f565b90506125fa82826125b3565b919050565b600080fd5b600080fd5b600080fd5b600067ffffffffffffffff82111561262957612628612584565b5b61263282612573565b9050602081019050919050565b82818337600083830152505050565b600061266161265c8461260e565b6125e4565b90508281526020810184848401111561267d5761267c612609565b5b61268884828561263f565b509392505050565b600082601f8301126126a5576126a4612604565b5b81356126b584826020860161264e565b91505092915050565b600067ffffffffffffffff82169050919050565b6126db816126be565b81146126e657600080fd5b50565b6000813590506126f8816126d2565b92915050565b600060e082840312156127145761271361256e565b5b61271e60e06125e4565b9050600082013567ffffffffffffffff81111561273e5761273d6125ff565b5b61274a84828501612690565b600083015250602082013567ffffffffffffffff81111561276e5761276d6125ff565b5b61277a84828501612690565b602083015250604061278e848285016126e9565b604083015250606082013567ffffffffffffffff8111156127b2576127b16125ff565b5b6127be84828501612690565b606083015250608082013567ffffffffffffffff8111156127e2576127e16125ff565b5b6127ee84828501612690565b60808301525060a0612802848285016126e9565b60a08301525060c082013567ffffffffffffffff811115612826576128256125ff565b5b61283284828501612690565b60c08301525092915050565b6000606082840312156128545761285361256e565b5b61285e60606125e4565b9050600082013567ffffffffffffffff81111561287e5761287d6125ff565b5b61288a848285016126fe565b600083015250602082013567ffffffffffffffff8111156128ae576128ad6125ff565b5b6128ba84828501612690565b60208301525060406128ce848285016126e9565b60408301525092915050565b6000602082840312156128f0576128ef6124a9565b5b600082013567ffffffffffffffff81111561290e5761290d6124ae565b5b61291a8482850161283e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061294e82612923565b9050919050565b61295e81612943565b811461296957600080fd5b50565b60008135905061297b81612955565b92915050565b6000604082840312156129975761299661256e565b5b6129a160406125e4565b9050600082013567ffffffffffffffff8111156129c1576129c06125ff565b5b6129cd848285016126fe565b60008301525060206129e18482850161296c565b60208301525092915050565b600060208284031215612a0357612a026124a9565b5b600082013567ffffffffffffffff811115612a2157612a206124ae565b5b612a2d84828501612981565b91505092915050565b6000819050919050565b612a4981612a36565b8114612a5457600080fd5b50565b600081359050612a6681612a40565b92915050565b600060c08284031215612a8257612a8161256e565b5b612a8c60c06125e4565b9050600082013567ffffffffffffffff811115612aac57612aab6125ff565b5b612ab884828501612690565b600083015250602082013567ffffffffffffffff811115612adc57612adb6125ff565b5b612ae884828501612690565b602083015250604082013567ffffffffffffffff811115612b0c57612b0b6125ff565b5b612b1884828501612690565b6040830152506060612b2c848285016126e9565b6060830152506080612b4084828501612a57565b60808301525060a0612b548482850161296c565b60a08301525092915050565b600060208284031215612b7657612b756124a9565b5b600082013567ffffffffffffffff811115612b9457612b936124ae565b5b612ba084828501612a6c565b91505092915050565b612bb281612a36565b82525050565b6000602082019050612bcd6000830184612ba9565b92915050565b612bdc81612943565b82525050565b6000602082019050612bf76000830184612bd3565b92915050565b6000819050919050565b612c1081612bfd565b8114612c1b57600080fd5b50565b600081359050612c2d81612c07565b92915050565b600060208284031215612c4957612c486124a9565b5b6000612c5784828501612c1e565b91505092915050565b612c6981612bfd565b82525050565b6000602082019050612c846000830184612c60565b92915050565b60008060408385031215612ca157612ca06124a9565b5b6000612caf85828601612c1e565b9250506020612cc08582860161296c565b9150509250929050565b600060208284031215612ce057612cdf6124a9565b5b6000612cee8482850161296c565b91505092915050565b60008060408385031215612d0e57612d0d6124a9565b5b6000612d1c85828601612a57565b9250506020612d2d85828601612a57565b9150509250929050565b600067ffffffffffffffff821115612d5257612d51612584565b5b602082029050602081019050919050565b600080fd5b6000612d7b612d7684612d37565b6125e4565b90508083825260208201905060208402830185811115612d9e57612d9d612d63565b5b835b81811015612de557803567ffffffffffffffff811115612dc357612dc2612604565b5b808601612dd08982612690565b85526020850194505050602081019050612da0565b5050509392505050565b600082601f830112612e0457612e03612604565b5b8135612e14848260208601612d68565b91505092915050565b60006101008284031215612e3457612e3361256e565b5b612e3f6101006125e4565b9050600082013567ffffffffffffffff811115612e5f57612e5e6125ff565b5b612e6b84828501612690565b600083015250602082013567ffffffffffffffff811115612e8f57612e8e6125ff565b5b612e9b84828501612690565b6020830152506040612eaf848285016126e9565b6040830152506060612ec38482850161296c565b6060830152506080612ed7848285016126e9565b60808301525060a082013567ffffffffffffffff811115612efb57612efa6125ff565b5b612f0784828501612def565b60a08301525060c0612f1b848285016126e9565b60c08301525060e082013567ffffffffffffffff811115612f3f57612f3e6125ff565b5b612f4b84828501612690565b60e08301525092915050565b600067ffffffffffffffff821115612f7257612f71612584565b5b602082029050602081019050919050565b600060408284031215612f9957612f9861256e565b5b612fa360406125e4565b9050600082013567ffffffffffffffff811115612fc357612fc26125ff565b5b612fcf84828501612690565b600083015250602082013567ffffffffffffffff811115612ff357612ff26125ff565b5b612fff84828501612690565b60208301525092915050565b600061301e61301984612f57565b6125e4565b9050808382526020820190506020840283018581111561304157613040612d63565b5b835b8181101561308857803567ffffffffffffffff81111561306657613065612604565b5b8086016130738982612f83565b85526020850194505050602081019050613043565b5050509392505050565b600082601f8301126130a7576130a6612604565b5b81356130b784826020860161300b565b91505092915050565b6000604082840312156130d6576130d561256e565b5b6130e060406125e4565b9050600082013567ffffffffffffffff811115613100576130ff6125ff565b5b61310c84828501612e1d565b600083015250602082013567ffffffffffffffff8111156131305761312f6125ff565b5b61313c84828501613092565b60208301525092915050565b60006040828403121561315e5761315d61256e565b5b61316860406125e4565b9050600082013567ffffffffffffffff811115613188576131876125ff565b5b613194848285016130c0565b60008301525060206131a88482850161296c565b60208301525092915050565b6000602082840312156131ca576131c96124a9565b5b600082013567ffffffffffffffff8111156131e8576131e76124ae565b5b6131f484828501613148565b91505092915050565b60008060408385031215613214576132136124a9565b5b60006132228582860161296c565b925050602083013567ffffffffffffffff811115613243576132426124ae565b5b61324f85828601612690565b9150509250929050565b600080fd5b60008083601f84011261327457613273612604565b5b8235905067ffffffffffffffff81111561329157613290613259565b5b6020830191508360208202830111156132ad576132ac612d63565b5b9250929050565b600080600080600080600060c0888a0312156132d3576132d26124a9565b5b60006132e18a828b01612a57565b97505060206132f28a828b01612a57565b96505060406133038a828b01612c1e565b955050606088013567ffffffffffffffff811115613324576133236124ae565b5b6133308a828b0161325e565b945094505060806133438a828b01612a57565b92505060a06133548a828b01612a57565b91505092959891949750929550565b6000604082840312156133795761337861256e565b5b61338360406125e4565b9050600082013567ffffffffffffffff8111156133a3576133a26125ff565b5b6133af8482850161283e565b60008301525060206133c38482850161296c565b60208301525092915050565b6000602082840312156133e5576133e46124a9565b5b600082013567ffffffffffffffff811115613403576134026124ae565b5b61340f84828501613363565b91505092915050565b60006020828403121561342e5761342d6124a9565b5b600082013567ffffffffffffffff81111561344c5761344b6124ae565b5b613458848285016126fe565b91505092915050565b600060c082840312156134775761347661256e565b5b61348160c06125e4565b9050600082013567ffffffffffffffff8111156134a1576134a06125ff565b5b6134ad84828501612690565b60008301525060206134c1848285016126e9565b602083015250604082013567ffffffffffffffff8111156134e5576134e46125ff565b5b6134f184828501612def565b6040830152506060613505848285016126e9565b606083015250608061351984828501612a57565b60808301525060a082013567ffffffffffffffff81111561353d5761353c6125ff565b5b61354984828501612690565b60a08301525092915050565b60006020828403121561356b5761356a6124a9565b5b600082013567ffffffffffffffff811115613589576135886124ae565b5b61359584828501613461565b91505092915050565b6000806000606084860312156135b7576135b66124a9565b5b60006135c58682870161296c565b93505060206135d68682870161296c565b92505060406135e78682870161296c565b9150509250925092565b600060208284031215613607576136066124a9565b5b600082013567ffffffffffffffff811115613625576136246124ae565b5b61363184828501612e1d565b91505092915050565b600080600060608486031215613653576136526124a9565b5b600061366186828701612a57565b935050602061367286828701612a57565b925050604061368386828701612c1e565b9150509250925092565b600060a082840312156136a3576136a261256e565b5b6136ad60a06125e4565b9050600082013567ffffffffffffffff8111156136cd576136cc6125ff565b5b6136d9848285016126fe565b600083015250602082013567ffffffffffffffff8111156136fd576136fc6125ff565b5b61370984828501612690565b602083015250604061371d848285016126e9565b604083015250606061373184828501612a57565b60608301525060806137458482850161296c565b60808301525092915050565b600060208284031215613767576137666124a9565b5b600082013567ffffffffffffffff811115613785576137846124ae565b5b6137918482850161368d565b91505092915050565b60008083601f8401126137b0576137af612604565b5b8235905067ffffffffffffffff8111156137cd576137cc613259565b5b6020830191508360208202830111156137e9576137e8612d63565b5b9250929050565b60008060008060006060868803121561380c5761380b6124a9565b5b600061381a88828901612a57565b955050602086013567ffffffffffffffff81111561383b5761383a6124ae565b5b6138478882890161379a565b9450945050604086013567ffffffffffffffff81111561386a576138696124ae565b5b6138768882890161325e565b92509250509295509295909350565b600081519050919050565b600082825260208201905092915050565b60005b838110156138bf5780820151818401526020810190506138a4565b60008484015250505050565b60006138d682613885565b6138e08185613890565b93506138f08185602086016138a1565b6138f981612573565b840191505092915050565b6000602082019050818103600083015261391e81846138cb565b905092915050565b60008151905061393581612a40565b92915050565b60008151905061394a81612c07565b92915050565b600080600060608486031215613969576139686124a9565b5b600061397786828701613926565b935050602061398886828701613926565b92505060406139998682870161393b565b9150509250925092565b6000602082840312156139b9576139b86124a9565b5b60006139c784828501613926565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613a0a82612a36565b9150613a1583612a36565b9250828202613a2381612a36565b91508282048414831517613a3a57613a396139d0565b5b5092915050565b6000613a4c82612a36565b9150613a5783612a36565b9250828201905080821115613a6f57613a6e6139d0565b5b92915050565b600082825260208201905092915050565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b6000613ae2602f83613a75565b9150613aed82613a86565b604082019050919050565b60006020820190508181036000830152613b1181613ad5565b9050919050565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f64656c656761746563616c6c0000000000000000000000000000000000000000602082015250565b6000613b74602c83613a75565b9150613b7f82613b18565b604082019050919050565b60006020820190508181036000830152613ba381613b67565b9050919050565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f6163746976652070726f78790000000000000000000000000000000000000000602082015250565b6000613c06602c83613a75565b9150613c1182613baa565b604082019050919050565b60006020820190508181036000830152613c3581613bf9565b9050919050565b7f555550535570677261646561626c653a206d757374206e6f742062652063616c60008201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000602082015250565b6000613c98603883613a75565b9150613ca382613c3c565b604082019050919050565b60006020820190508181036000830152613cc781613c8b565b9050919050565b6000613ce1613cdc8461260e565b6125e4565b905082815260208101848484011115613cfd57613cfc612609565b5b613d088482856138a1565b509392505050565b600082601f830112613d2557613d24612604565b5b8151613d35848260208601613cce565b91505092915050565b600060208284031215613d5457613d536124a9565b5b600082015167ffffffffffffffff811115613d7257613d716124ae565b5b613d7e84828501613d10565b91505092915050565b7f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201527f647920696e697469616c697a6564000000000000000000000000000000000000602082015250565b6000613de3602e83613a75565b9150613dee82613d87565b604082019050919050565b60006020820190508181036000830152613e1281613dd6565b9050919050565b6000819050919050565b600060ff82169050919050565b6000819050919050565b6000613e55613e50613e4b84613e19565b613e30565b613e23565b9050919050565b613e6581613e3a565b82525050565b6000602082019050613e806000830184613e5c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613ecb57613eca6124a9565b5b6000613ed98482850161393b565b91505092915050565b7f45524331393637557067726164653a206e657720696d706c656d656e7461746960008201527f6f6e206973206e6f742055555053000000000000000000000000000000000000602082015250565b6000613f3e602e83613a75565b9150613f4982613ee2565b604082019050919050565b60006020820190508181036000830152613f6d81613f31565b9050919050565b7f45524331393637557067726164653a20756e737570706f727465642070726f7860008201527f6961626c65555549440000000000000000000000000000000000000000000000602082015250565b6000613fd0602983613a75565b9150613fdb82613f74565b604082019050919050565b60006020820190508181036000830152613fff81613fc3565b9050919050565b6000819050919050565b61402161401c82612bfd565b614006565b82525050565b60006140338284614010565b60208201915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061407c82612a36565b915061408783612a36565b92508261409757614096614042565b5b828206905092915050565b60006140ae8285614010565b6020820191506140be8284614010565b6020820191508190509392505050565b60006140d982612a36565b91506140e483612a36565b9250826140f4576140f3614042565b5b828204905092915050565b600061410a82612a36565b915061411583612a36565b925082820390508181111561412d5761412c6139d0565b5b92915050565b7f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960008201527f6e697469616c697a696e67000000000000000000000000000000000000000000602082015250565b600061418f602b83613a75565b915061419a82614133565b604082019050919050565b600060208201905081810360008301526141be81614182565b9050919050565b600081905092915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b60006142066017836141c5565b9150614211826141d0565b601782019050919050565b600081519050919050565b60006142328261421c565b61423c81856141c5565b935061424c8185602086016138a1565b80840191505092915050565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b600061428e6011836141c5565b915061429982614258565b601182019050919050565b60006142af826141f9565b91506142bb8285614227565b91506142c682614281565b91506142d28284614227565b91508190509392505050565b60006142e98261421c565b6142f38185613a75565b93506143038185602086016138a1565b61430c81612573565b840191505092915050565b6000602082019050818103600083015261433181846142de565b905092915050565b7f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60008201527f6f74206120636f6e747261637400000000000000000000000000000000000000602082015250565b6000614395602d83613a75565b91506143a082614339565b604082019050919050565b600060208201905081810360008301526143c481614388565b9050919050565b60006143d682612a36565b9150600082036143e9576143e86139d0565b5b600182039050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b600061442a602083613a75565b9150614435826143f4565b602082019050919050565b600060208201905081810360008301526144598161441d565b9050919050565b7f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60008201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b60006144bc602683613a75565b91506144c782614460565b604082019050919050565b600060208201905081810360008301526144eb816144af565b9050919050565b600081905092915050565b600061450882613885565b61451281856144f2565b93506145228185602086016138a1565b80840191505092915050565b600061453a82846144fd565b91508190509291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122014b7f655743616a457a79f64363660819009eedfff0ddd4389f3e9db93c4445664736f6c63430008140033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
0x5a3c35CCC5c05fDeFe5Ecafc15F4B1aC8eF71481
Loading...
Loading
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.