Contract 0x00000000fc1237824fb747abde0ff18990e59b7e 6

 
Txn Hash Method
Block
From
To
Value
0x0cffefb0c9aaaf2ee8cb83ace1f2d65d01f244e814a66fa8aa15e848dc6cb844Remove For1164748692024-02-21 20:48:351 hr 2 mins ago0x2956be76d7164486ad89aa748db054ff91ffbfcd IN  Farcaster: Key Registry0 ETH0.0001157500170.003180885
0xc4363fec4435f6362cbe7f0f23260f437683fe812f428a7e77dc532288295d2aRemove For1164733472024-02-21 19:57:511 hr 52 mins ago0xf6ea479f30a71cc8cb28dc28f9a94246e1edc492 IN  Farcaster: Key Registry0 ETH0.0001231010960.004037218
0x2c936468628bd5ca3086ee69a86eaacb4dbe79caa8b460645b1a153304093c46Remove1164358852024-02-20 23:09:0722 hrs 41 mins ago0xa8c378eb975492d9257b0ae63bb309f5aeebcf3d IN  Farcaster: Key Registry0 ETH0.0000959452420.004028946
0x3702d45d6fc5db1adcc750340aca855392fe4080e63065153c1feefae5a58f92Remove For1164291472024-02-20 19:24:311 day 2 hrs ago0x3f6b7c4870de594418d7c52f32de501edec75673 IN  Farcaster: Key Registry0 ETH0.0001319947290.004500923
0x12be7de60b8a56f42fc89f5bda88b318e255a9815fc50e89be991e7954e2046bRemove For1164287512024-02-20 19:11:191 day 2 hrs ago0xbe0c12b56aa9b4f5dde36c733b3a2997ed775a4f IN  Farcaster: Key Registry0 ETH0.0001072011480.004440313
0x7160fae7b43d28a551bbbc292ba7e46e59c4073b21bd972347f48ba2e795b5a8Remove1164116972024-02-20 9:42:511 day 12 hrs ago0xbfec04be4ad8c51fe351e41d31cddaea968f52f2 IN  Farcaster: Key Registry0 ETH0.0000627553870.004036694
0x0c7e76ead0d60d98beb93b7a3d6b2738e5493b60ccb552bcd987eabcd0af26ccRemove1164113932024-02-20 9:32:431 day 12 hrs ago0x1d3cb273ecd020314d2a27dee21f760808e916a3 IN  Farcaster: Key Registry0 ETH0.0000844015660.004199297
0x9b64caf22cc56a96deddad260dc5cf4d7825cbffc64260583e3107b38dabae3dRemove1164113852024-02-20 9:32:271 day 12 hrs ago0x1d3cb273ecd020314d2a27dee21f760808e916a3 IN  Farcaster: Key Registry0 ETH0.000083606290.004369883
0x282488f70a779462a637203211b949f9d91ecdcab833b5932bdd7a039613517dRemove For1164087132024-02-20 8:03:231 day 13 hrs ago0xf6ea479f30a71cc8cb28dc28f9a94246e1edc492 IN  Farcaster: Key Registry0 ETH0.0000953716310.004818227
0xefdae075f67b478500f0e48b79124d1ccba9a48c682bb5ff3b0831ba865b0a35Remove For1163962682024-02-20 1:08:331 day 20 hrs ago0x3f6b7c4870de594418d7c52f32de501edec75673 IN  Farcaster: Key Registry0 ETH0.0000834428840.004579966
0xeed36868084422f80e011e6ce81768432e1ff8dca02646fb7e063dc106fc1f9dRemove For1163889072024-02-19 21:03:112 days 47 mins ago0x2d93c2f74b2c4697f9ea85d0450148aa45d4d5a2 IN  Farcaster: Key Registry0 ETH0.000216033340.004240576
0x3d61795752cd5fff480c94540843c0b8adfc6469fa2b0b6a18d4b47d962216abRemove For1163857392024-02-19 19:17:352 days 2 hrs ago0x3f6b7c4870de594418d7c52f32de501edec75673 IN  Farcaster: Key Registry0 ETH0.0001534974080.004627897
0x03de340cd2bed81f22606df74fdc7178a71b31c4511a11fe3c4126e9bcc75edbRemove1163807662024-02-19 16:31:492 days 5 hrs ago0xa9f9c0eac673e215e7f18b38531b24c6b8edf861 IN  Farcaster: Key Registry0 ETH0.0001261389510.004206735
0x64ae81014b5b881e184003aaa4b000e71ee3d32cf60483ecd1fb636b0da800b1Remove For1163797192024-02-19 15:56:552 days 5 hrs ago0xf6ea479f30a71cc8cb28dc28f9a94246e1edc492 IN  Farcaster: Key Registry0 ETH0.0001477466810.00649656
0x6a73e2e8d63a086014fb2316f0496aae496cf99cb8d368fbfa96be1101c2be6fRemove For1163755442024-02-19 13:37:452 days 8 hrs ago0xf6ea479f30a71cc8cb28dc28f9a94246e1edc492 IN  Farcaster: Key Registry0 ETH0.0001525024480.008260666
0x21ca25a4f6272f727353a9fd2ae8ce25f00f1ac48f676b6ba1a0d4af8e420a01Remove For1163755342024-02-19 13:37:252 days 8 hrs ago0x3a4afca659f54922a0d7a7b0bebabf641dec66bb IN  Farcaster: Key Registry0 ETH0.0001590012820.007921959
0xe6177c9121a28cb41f2e6e226f35bbb6b9d3a5fa454854f5888a11fad2d24240Remove For1163633642024-02-19 6:51:452 days 14 hrs ago0xbe0c12b56aa9b4f5dde36c733b3a2997ed775a4f IN  Farcaster: Key Registry0 ETH0.0000765511790.005473179
0x71e44b6e727c37f947d32d24811013392ed6de5f8b1112ef0ad5dd34b04bdf50Remove1163462812024-02-18 21:22:193 days 28 mins ago0x10583c3da99f7e980f58a778aed174ddda2a4812 IN  Farcaster: Key Registry0 ETH0.000044780710.004453408
0xdd194cb5a2856c01b42e378ab5139e9e15af3ca8e517e148c389d9ed06144870Remove For1163386352024-02-18 17:07:273 days 4 hrs ago0x3d5750d305f8d9c133faceaa92a2e46558130371 IN  Farcaster: Key Registry0 ETH0.0000993122070.005175718
0x78800e35ac624a057630ab3f28fa76079ba1864f4bd7ae55b0bd0940ab5f1c8dRemove For1163386272024-02-18 17:07:113 days 4 hrs ago0x3d5750d305f8d9c133faceaa92a2e46558130371 IN  Farcaster: Key Registry0 ETH0.0001159765150.005196941
0x52483ada58558c1c20400eb2071c4690f36340f3a8d03bca4b07648fc79e7448Remove For1163352392024-02-18 15:14:153 days 6 hrs ago0xbe0c12b56aa9b4f5dde36c733b3a2997ed775a4f IN  Farcaster: Key Registry0 ETH0.0001093070370.00571369
0x40e10ee269c6956a7aea562bc2bd04069eb1395688e5fd16718008852af403f5Remove For1163196972024-02-18 6:36:113 days 15 hrs ago0xb6bc506d4c191d61df37bb058ed061337a848dd9 IN  Farcaster: Key Registry0 ETH0.0000619242920.005406128
0xfc5b5066f0c005e71933ef21c925d6a5e1bf764a5e218e7536ddd5f30317f3d7Remove For1163117612024-02-18 2:11:393 days 19 hrs ago0x3a4afca659f54922a0d7a7b0bebabf641dec66bb IN  Farcaster: Key Registry0 ETH0.000056729080.00503318
0x7a37e4051e38ee43cecbc2e4a7e4a51851030dc3480a4d1dda032f245dba246eRemove For1162920442024-02-17 15:14:254 days 6 hrs ago0xbe0c12b56aa9b4f5dde36c733b3a2997ed775a4f IN  Farcaster: Key Registry0 ETH0.0000983161910.005103236
0x110a3d1022046e0d60d6276b732182fcf6caa016490c8f3fb32afc92e5d2354aRemove For1162781922024-02-17 7:32:414 days 14 hrs ago0xf6ea479f30a71cc8cb28dc28f9a94246e1edc492 IN  Farcaster: Key Registry0 ETH0.0000527707630.00565647
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0x79f5118f6bece3e5690dc7e64be9f582cecc66f42e68cc7e5be83370489fe67b1118163592023-11-06 0:44:55107 days 21 hrs ago 0x0000000000ffe8b47b3e2130213b802212439497  Contract Creation0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
KeyRegistry

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 100000 runs

Other Settings:
paris EvmVersion
File 1 of 30 : KeyRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import {Ownable2Step} from "openzeppelin/contracts/access/Ownable2Step.sol";

import {IKeyRegistry} from "./interfaces/IKeyRegistry.sol";
import {IMetadataValidator} from "./interfaces/IMetadataValidator.sol";
import {IdRegistryLike} from "./interfaces/IdRegistryLike.sol";
import {EIP712} from "./abstract/EIP712.sol";
import {Migration} from "./abstract/Migration.sol";
import {Nonces} from "./abstract/Nonces.sol";
import {Signatures} from "./abstract/Signatures.sol";
import {EnumerableKeySet, KeySet} from "./libraries/EnumerableKeySet.sol";

/**
 * @title Farcaster KeyRegistry
 *
 * @notice See https://github.com/farcasterxyz/contracts/blob/v3.1.0/docs/docs.md for an overview.
 *
 * @custom:security-contact [email protected]
 */
contract KeyRegistry is IKeyRegistry, Migration, Signatures, EIP712, Nonces {
    using EnumerableKeySet for KeySet;

    /*//////////////////////////////////////////////////////////////
                              CONSTANTS
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IKeyRegistry
     */
    string public constant VERSION = "2023.11.15";

    /**
     * @inheritdoc IKeyRegistry
     */
    bytes32 public constant REMOVE_TYPEHASH =
        keccak256("Remove(address owner,bytes key,uint256 nonce,uint256 deadline)");

    /*//////////////////////////////////////////////////////////////
                                STORAGE
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IKeyRegistry
     */
    IdRegistryLike public idRegistry;

    /**
     * @inheritdoc IKeyRegistry
     */
    address public keyGateway;

    /**
     * @inheritdoc IKeyRegistry
     */
    bool public gatewayFrozen;

    /**
     * @inheritdoc IKeyRegistry
     */
    uint256 public maxKeysPerFid;

    /**
     * @dev Internal enumerable set tracking active keys by fid.
     */
    mapping(uint256 fid => KeySet activeKeys) internal _activeKeysByFid;

    /**
     * @dev Internal enumerable set tracking removed keys by fid.
     */
    mapping(uint256 fid => KeySet removedKeys) internal _removedKeysByFid;

    /**
     * @dev Mapping of fid to a key to the key's data.
     *
     * @custom:param fid       The fid associated with the key.
     * @custom:param key       Bytes of the key.
     * @custom:param data      Struct with the state and key type. In the initial migration
     *                         all keys will have data.keyType == 1.
     */
    mapping(uint256 fid => mapping(bytes key => KeyData data)) public keys;

    /**
     * @dev Mapping of keyType to metadataType to validator contract.
     *
     * @custom:param keyType      Numeric keyType.
     * @custom:param metadataType Metadata metadataType.
     * @custom:param validator    Validator contract implementing IMetadataValidator.
     */
    mapping(uint32 keyType => mapping(uint8 metadataType => IMetadataValidator validator)) public validators;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set the IdRegistry and owner.
     *
     * @param _idRegistry    IdRegistry contract address.
     * @param _migrator      Migrator address.
     * @param _initialOwner  Initial contract owner address.
     * @param _maxKeysPerFid Maximum number of keys per fid.
     */
    constructor(
        address _idRegistry,
        address _migrator,
        address _initialOwner,
        uint256 _maxKeysPerFid
    ) Migration(24 hours, _migrator, _initialOwner) EIP712("Farcaster KeyRegistry", "1") {
        idRegistry = IdRegistryLike(_idRegistry);
        maxKeysPerFid = _maxKeysPerFid;
        emit SetIdRegistry(address(0), _idRegistry);
        emit SetMaxKeysPerFid(0, _maxKeysPerFid);
    }

    /*//////////////////////////////////////////////////////////////
                                  VIEWS
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IKeyRegistry
     */
    function totalKeys(uint256 fid, KeyState state) public view virtual returns (uint256) {
        return _keysByState(fid, state).length();
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function keyAt(uint256 fid, KeyState state, uint256 index) external view returns (bytes memory) {
        return _keysByState(fid, state).at(index);
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function keysOf(uint256 fid, KeyState state) external view returns (bytes[] memory) {
        return _keysByState(fid, state).values();
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function keysOf(
        uint256 fid,
        KeyState state,
        uint256 startIdx,
        uint256 batchSize
    ) external view returns (bytes[] memory page, uint256 nextIdx) {
        KeySet storage _keys = _keysByState(fid, state);
        uint256 len = _keys.length();
        if (startIdx >= len) return (new bytes[](0), 0);

        uint256 remaining = len - startIdx;
        uint256 adjustedBatchSize = remaining < batchSize ? remaining : batchSize;

        page = new bytes[](adjustedBatchSize);
        for (uint256 i = 0; i < adjustedBatchSize; i++) {
            page[i] = _keys.at(startIdx + i);
        }

        nextIdx = startIdx + adjustedBatchSize;
        if (nextIdx >= len) nextIdx = 0;

        return (page, nextIdx);
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function keyDataOf(uint256 fid, bytes calldata key) external view returns (KeyData memory) {
        return keys[fid][key];
    }

    /*//////////////////////////////////////////////////////////////
                              REGISTRATION
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IKeyRegistry
     */
    function add(
        address fidOwner,
        uint32 keyType,
        bytes calldata key,
        uint8 metadataType,
        bytes calldata metadata
    ) external whenNotPaused {
        if (msg.sender != keyGateway) revert Unauthorized();
        _add(_fidOf(fidOwner), keyType, key, metadataType, metadata);
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function remove(bytes calldata key) external whenNotPaused {
        _remove(_fidOf(msg.sender), key);
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function removeFor(
        address fidOwner,
        bytes calldata key,
        uint256 deadline,
        bytes calldata sig
    ) external whenNotPaused {
        _verifyRemoveSig(fidOwner, key, deadline, sig);
        _remove(_fidOf(fidOwner), key);
    }

    /*//////////////////////////////////////////////////////////////
                                MIGRATION
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IKeyRegistry
     */
    function bulkAddKeysForMigration(BulkAddData[] calldata items) external onlyMigrator {
        // Safety: i and j can be incremented unchecked since they are bound by items.length and
        // items[i].keys.length respectively.
        unchecked {
            for (uint256 i = 0; i < items.length; i++) {
                BulkAddData calldata item = items[i];
                for (uint256 j = 0; j < item.keys.length; j++) {
                    _add(item.fid, 1, item.keys[j].key, 1, item.keys[j].metadata, false);
                }
            }
        }
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function bulkResetKeysForMigration(BulkResetData[] calldata items) external onlyMigrator {
        // Safety: i and j can be incremented unchecked since they are bound by items.length and
        // items[i].keys.length respectively.
        unchecked {
            for (uint256 i = 0; i < items.length; i++) {
                BulkResetData calldata item = items[i];
                for (uint256 j = 0; j < item.keys.length; j++) {
                    _reset(item.fid, item.keys[j]);
                }
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                                 ADMIN
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IKeyRegistry
     */
    function setValidator(uint32 keyType, uint8 metadataType, IMetadataValidator validator) external onlyOwner {
        if (keyType == 0) revert InvalidKeyType();
        if (metadataType == 0) revert InvalidMetadataType();
        emit SetValidator(keyType, metadataType, address(validators[keyType][metadataType]), address(validator));
        validators[keyType][metadataType] = validator;
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function setIdRegistry(address _idRegistry) external onlyOwner {
        emit SetIdRegistry(address(idRegistry), _idRegistry);
        idRegistry = IdRegistryLike(_idRegistry);
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function setKeyGateway(address _keyGateway) external onlyOwner {
        if (gatewayFrozen) revert GatewayFrozen();
        emit SetKeyGateway(keyGateway, _keyGateway);
        keyGateway = _keyGateway;
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function freezeKeyGateway() external onlyOwner {
        if (gatewayFrozen) revert GatewayFrozen();
        emit FreezeKeyGateway(keyGateway);
        gatewayFrozen = true;
    }

    /**
     * @inheritdoc IKeyRegistry
     */
    function setMaxKeysPerFid(uint256 _maxKeysPerFid) external onlyOwner {
        if (_maxKeysPerFid <= maxKeysPerFid) revert InvalidMaxKeys();
        emit SetMaxKeysPerFid(maxKeysPerFid, _maxKeysPerFid);
        maxKeysPerFid = _maxKeysPerFid;
    }

    /*//////////////////////////////////////////////////////////////
                                 HELPERS
    //////////////////////////////////////////////////////////////*/

    function _add(
        uint256 fid,
        uint32 keyType,
        bytes calldata key,
        uint8 metadataType,
        bytes calldata metadata
    ) internal {
        _add(fid, keyType, key, metadataType, metadata, true);
    }

    function _add(
        uint256 fid,
        uint32 keyType,
        bytes calldata key,
        uint8 metadataType,
        bytes calldata metadata,
        bool validate
    ) internal {
        KeyData storage keyData = keys[fid][key];
        if (keyData.state != KeyState.NULL) revert InvalidState();
        if (totalKeys(fid, KeyState.ADDED) >= maxKeysPerFid) revert ExceedsMaximum();

        IMetadataValidator validator = validators[keyType][metadataType];
        if (validator == IMetadataValidator(address(0))) {
            revert ValidatorNotFound(keyType, metadataType);
        }

        _addToKeySet(fid, key);
        keyData.state = KeyState.ADDED;
        keyData.keyType = keyType;
        emit Add(fid, keyType, key, key, metadataType, metadata);

        if (validate) {
            bool isValid = validator.validate(fid, key, metadata);
            if (!isValid) revert InvalidMetadata();
        }
    }

    function _remove(uint256 fid, bytes calldata key) internal {
        KeyData storage keyData = keys[fid][key];
        if (keyData.state != KeyState.ADDED) revert InvalidState();

        _removeFromKeySet(fid, key);
        keyData.state = KeyState.REMOVED;
        emit Remove(fid, key, key);
    }

    function _reset(uint256 fid, bytes calldata key) internal {
        KeyData storage keyData = keys[fid][key];
        if (keyData.state != KeyState.ADDED) revert InvalidState();

        _resetFromKeySet(fid, key);
        keyData.state = KeyState.NULL;
        delete keyData.keyType;
        emit AdminReset(fid, key, key);
    }

    /*//////////////////////////////////////////////////////////////
                     SIGNATURE VERIFICATION HELPERS
    //////////////////////////////////////////////////////////////*/

    function _verifyRemoveSig(address fidOwner, bytes calldata key, uint256 deadline, bytes calldata sig) internal {
        _verifySig(
            _hashTypedDataV4(
                keccak256(abi.encode(REMOVE_TYPEHASH, fidOwner, keccak256(key), _useNonce(fidOwner), deadline))
            ),
            fidOwner,
            deadline,
            sig
        );
    }

    /*//////////////////////////////////////////////////////////////
                           FID HELPERS
    //////////////////////////////////////////////////////////////*/

    function _fidOf(address fidOwner) internal view returns (uint256 fid) {
        fid = idRegistry.idOf(fidOwner);
        if (fid == 0) revert Unauthorized();
    }

    /*//////////////////////////////////////////////////////////////
                         KEY SET HELPERS
    //////////////////////////////////////////////////////////////*/

    function _addToKeySet(uint256 fid, bytes calldata key) internal virtual {
        _activeKeysByFid[fid].add(key);
    }

    function _removeFromKeySet(uint256 fid, bytes calldata key) internal virtual {
        _activeKeysByFid[fid].remove(key);
        _removedKeysByFid[fid].add(key);
    }

    function _resetFromKeySet(uint256 fid, bytes calldata key) internal virtual {
        _activeKeysByFid[fid].remove(key);
    }

    function _keysByState(uint256 fid, KeyState state) internal view returns (KeySet storage) {
        if (state == KeyState.ADDED) {
            return _activeKeysByFid[fid];
        } else if (state == KeyState.REMOVED) {
            return _removedKeysByFid[fid];
        } else {
            revert InvalidState();
        }
    }
}

File 2 of 30 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}

File 3 of 30 : IKeyRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

import {IMetadataValidator} from "./IMetadataValidator.sol";
import {IdRegistryLike} from "./IdRegistryLike.sol";

interface IKeyRegistry {
    /*//////////////////////////////////////////////////////////////
                                 ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @dev Revert if a key violates KeyState transition rules.
    error InvalidState();

    /// @dev Revert if adding a key exceeds the maximum number of allowed keys per fid.
    error ExceedsMaximum();

    /// @dev Revert if a validator has not been registered for this keyType and metadataType.
    error ValidatorNotFound(uint32 keyType, uint8 metadataType);

    /// @dev Revert if metadata validation failed.
    error InvalidMetadata();

    /// @dev Revert if the admin sets a validator for keyType 0.
    error InvalidKeyType();

    /// @dev Revert if the admin sets a validator for metadataType 0.
    error InvalidMetadataType();

    /// @dev Revert if the caller does not have the authority to perform the action.
    error Unauthorized();

    /// @dev Revert if the owner sets maxKeysPerFid equal to or below its current value.
    error InvalidMaxKeys();

    /// @dev Revert when the gateway dependency is permanently frozen.
    error GatewayFrozen();

    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    /**
     * @dev Emit an event when an admin or fid adds a new key.
     *
     *      Hubs listen for this, validate that keyBytes is an EdDSA pub key and keyType == 1 and
     *      add keyBytes to its SignerStore. Messages signed by keyBytes with `fid` are now valid
     *      and accepted over gossip, sync and client apis. Hubs assume the invariants:
     *
     *      1. Add(fid, ..., key, keyBytes, ...) cannot emit if there is an earlier emit with
     *         Add(fid, ..., key, keyBytes, ...) and no AdminReset(fid, key, keyBytes) inbetween.
     *
     *      2. Add(fid, ..., key, keyBytes, ...) cannot emit if there is an earlier emit with
     *         Remove(fid, key, keyBytes).
     *
     *      3. For all Add(..., ..., key, keyBytes, ...), key = keccak(keyBytes)
     *
     * @param fid          The fid associated with the key.
     * @param keyType      The type of the key.
     * @param key          The key being registered. (indexed as hash)
     * @param keyBytes     The bytes of the key being registered.
     * @param metadataType The type of the metadata.
     * @param metadata     Metadata about the key.
     */
    event Add(
        uint256 indexed fid,
        uint32 indexed keyType,
        bytes indexed key,
        bytes keyBytes,
        uint8 metadataType,
        bytes metadata
    );

    /**
     * @dev Emit an event when an fid removes an added key.
     *
     *      Hubs listen for this, validate that keyType == 1 and keyBytes exists in its SignerStore.
     *      keyBytes is marked as removed, messages signed by keyBytes with `fid` are invalid,
     *      dropped immediately and no longer accepted. Hubs assume the invariants:
     *
     *      1. Remove(fid, key, keyBytes) cannot emit if there is no earlier emit with
     *         Add(fid, ..., key, keyBytes, ...)
     *
     *      2. Remove(fid, key, keyBytes) cannot emit if there is an earlier emit with
     *         Remove(fid, key, keyBytes)
     *
     *      3. For all Remove(..., key, keyBytes), key = keccak(keyBytes)
     *
     * @param fid       The fid associated with the key.
     * @param key       The key being registered. (indexed as hash)
     * @param keyBytes  The bytes of the key being registered.
     */
    event Remove(uint256 indexed fid, bytes indexed key, bytes keyBytes);

    /**
     * @dev Emit an event when an admin resets an added key.
     *
     *      Hubs listen for this, validate that keyType == 1 and that keyBytes exists in its SignerStore.
     *      keyBytes is no longer tracked, messages signed by keyBytes with `fid` are invalid, dropped
     *      immediately and not accepted. Hubs assume the following invariants:
     *
     *      1. AdminReset(fid, key, keyBytes) cannot emit unless the most recent event for the fid
     *         was Add(fid, ..., key, keyBytes, ...).
     *
     *      2. For all AdminReset(..., key, keyBytes), key = keccak(keyBytes).
     *
     *      3. AdminReset() cannot emit after Migrated().
     *
     * @param fid       The fid associated with the key.
     * @param key       The key being reset. (indexed as hash)
     * @param keyBytes  The bytes of the key being registered.
     */
    event AdminReset(uint256 indexed fid, bytes indexed key, bytes keyBytes);

    /**
     * @dev Emit an event when the admin sets a metadata validator contract for a given
     *      keyType and metadataType.
     *
     * @param keyType      The numeric keyType associated with this validator.
     * @param metadataType The metadataType associated with this validator.
     * @param oldValidator The previous validator contract address.
     * @param newValidator The new validator contract address.
     */
    event SetValidator(uint32 keyType, uint8 metadataType, address oldValidator, address newValidator);

    /**
     * @dev Emit an event when the admin sets a new IdRegistry contract address.
     *
     * @param oldIdRegistry The previous IdRegistry address.
     * @param newIdRegistry The new IdRegistry address.
     */
    event SetIdRegistry(address oldIdRegistry, address newIdRegistry);

    /**
     * @dev Emit an event when the admin sets a new KeyGateway address.
     *
     * @param oldKeyGateway The previous KeyGateway address.
     * @param newKeyGateway The new KeyGateway address.
     */
    event SetKeyGateway(address oldKeyGateway, address newKeyGateway);

    /**
     * @dev Emit an event when the admin sets a new maximum keys per fid.
     *
     * @param oldMax The previous maximum.
     * @param newMax The new maximum.
     */
    event SetMaxKeysPerFid(uint256 oldMax, uint256 newMax);

    /**
     * @dev Emit an event when the contract owner permanently freezes the KeyGateway address.
     *
     * @param keyGateway The permanent KeyGateway address.
     */
    event FreezeKeyGateway(address keyGateway);

    /*//////////////////////////////////////////////////////////////
                                 STRUCTS
    //////////////////////////////////////////////////////////////*/

    /**
     *  @notice State enumeration for a key in the registry. During migration, an admin can change
     *          the state of any fids key from NULL to ADDED or ADDED to NULL. After migration, an
     *          fid can change the state of a key from NULL to ADDED or ADDED to REMOVED only.
     *
     *          - NULL: The key is not in the registry.
     *          - ADDED: The key has been added to the registry.
     *          - REMOVED: The key was added to the registry but is now removed.
     */
    enum KeyState {
        NULL,
        ADDED,
        REMOVED
    }

    /**
     *  @notice Data about a key.
     *
     *  @param state   The current state of the key.
     *  @param keyType Numeric ID representing the manner in which the key should be used.
     */
    struct KeyData {
        KeyState state;
        uint32 keyType;
    }

    /**
     * @dev Struct argument for bulk add function, representing an FID
     *      and its associated keys.
     *
     * @param fid  Fid associated with provided keys to add.
     * @param keys Array of BulkAddKey structs, including key and metadata.
     */
    struct BulkAddData {
        uint256 fid;
        BulkAddKey[] keys;
    }

    /**
     * @dev Struct argument for bulk add function, representing a key
     *      and its associated metadata.
     *
     * @param key  Bytes of the signer key.
     * @param keys Metadata metadata of the signer key.
     */
    struct BulkAddKey {
        bytes key;
        bytes metadata;
    }

    /**
     * @dev Struct argument for bulk reset function, representing an FID
     *      and its associated keys.
     *
     * @param fid  Fid associated with provided keys to reset.
     * @param keys Array of keys to reset.
     */
    struct BulkResetData {
        uint256 fid;
        bytes[] keys;
    }

    /*//////////////////////////////////////////////////////////////
                              CONSTANTS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Contract version specified in the Farcaster protocol version scheme.
     */
    function VERSION() external view returns (string memory);

    /**
     * @notice EIP-712 typehash for Remove signatures.
     */
    function REMOVE_TYPEHASH() external view returns (bytes32);

    /*//////////////////////////////////////////////////////////////
                                STORAGE
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice The IdRegistry contract.
     */
    function idRegistry() external view returns (IdRegistryLike);

    /**
     * @notice The KeyGateway address.
     */
    function keyGateway() external view returns (address);

    /**
     * @notice Whether the KeyGateway address is permanently frozen.
     */
    function gatewayFrozen() external view returns (bool);

    /**
     * @notice Maximum number of keys per fid.
     */
    function maxKeysPerFid() external view returns (uint256);

    /*//////////////////////////////////////////////////////////////
                                  VIEWS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Return number of active keys for a given fid.
     *
     * @param fid the fid associated with the keys.
     *
     * @return uint256 total number of active keys associated with the fid.
     */
    function totalKeys(uint256 fid, KeyState state) external view returns (uint256);

    /**
     * @notice Return key at the given index in the fid's key set. Can be
     *         called to enumerate all active keys for a given fid.
     *
     * @param fid   the fid associated with the key.
     * @param index index of the key in the fid's key set. Must be a value
     *              less than totalKeys(fid). Note that because keys are
     *              stored in an underlying enumerable set, the ordering of
     *              keys is not guaranteed to be stable.
     *
     * @return bytes Bytes of the key.
     */
    function keyAt(uint256 fid, KeyState state, uint256 index) external view returns (bytes memory);

    /**
     * @notice Return an array of all active keys for a given fid.
     * @dev    WARNING: This function will copy the entire key set to memory,
     *         which can be quite expensive. This is intended to be called
     *         offchain with eth_call, not onchain.
     *
     * @param fid the fid associated with the keys.
     *
     * @return bytes[] Array of all keys.
     */
    function keysOf(uint256 fid, KeyState state) external view returns (bytes[] memory);

    /**
     * @notice Return an array of all active keys for a given fid,
     *         paged by index and batch size.
     *
     * @param fid       The fid associated with the keys.
     * @param startIdx  Start index of lookup.
     * @param batchSize Number of items to return.
     *
     * @return page    Array of keys.
     * @return nextIdx Next index in the set of all keys.
     */
    function keysOf(
        uint256 fid,
        KeyState state,
        uint256 startIdx,
        uint256 batchSize
    ) external view returns (bytes[] memory page, uint256 nextIdx);

    /**
     * @notice Retrieve state and type data for a given key.
     *
     * @param fid   The fid associated with the key.
     * @param key   Bytes of the key.
     *
     * @return KeyData struct that contains the state and keyType.
     */
    function keyDataOf(uint256 fid, bytes calldata key) external view returns (KeyData memory);

    /*//////////////////////////////////////////////////////////////
                              REMOVE KEYS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Remove a key associated with the caller's fid, setting the key state to REMOVED.
     *         The key must be in the ADDED state.
     *
     * @param key   Bytes of the key to remove.
     */
    function remove(bytes calldata key) external;

    /**
     * @notice Remove a key on behalf of another fid owner, setting the key state to REMOVED.
     *         caller must supply a valid EIP-712 Remove signature from the fid owner.
     *
     * @param fidOwner The fid owner address.
     * @param key      Bytes of the key to remove.
     * @param deadline Deadline after which the signature expires.
     * @param sig      EIP-712 Remove signature generated by fid owner.
     */
    function removeFor(address fidOwner, bytes calldata key, uint256 deadline, bytes calldata sig) external;

    /*//////////////////////////////////////////////////////////////
                         PERMISSIONED ACTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Add a key associated with fidOwner's fid, setting the key state to ADDED.
     *         Can only be called by the keyGateway address.
     *
     * @param keyType      The key's numeric keyType.
     * @param key          Bytes of the key to add.
     * @param metadataType Metadata type ID.
     * @param metadata     Metadata about the key, which is not stored and only emitted in an event.
     */
    function add(
        address fidOwner,
        uint32 keyType,
        bytes calldata key,
        uint8 metadataType,
        bytes calldata metadata
    ) external;

    /**
     * @notice Add multiple keys as part of the initial migration. Only callable by the contract owner.
     *
     * @param items An array of BulkAddData structs including fid and array of BulkAddKey structs.
     */
    function bulkAddKeysForMigration(BulkAddData[] calldata items) external;

    /**
     * @notice Reset multiple keys as part of the initial migration. Only callable by the contract owner.
     *         Reset is not the same as removal: this function sets the key state back to NULL,
     *         rather than REMOVED. This allows the owner to correct any errors in the initial migration until
     *         the grace period expires.
     *
     * @param items   A list of BulkResetData structs including an fid and array of keys.
     */
    function bulkResetKeysForMigration(BulkResetData[] calldata items) external;

    /**
     * @notice Set a metadata validator contract for the given keyType and metadataType. Only callable by owner.
     *
     * @param keyType      The numeric key type ID associated with this validator.
     * @param metadataType The numeric metadata type ID associated with this validator.
     * @param validator    Contract implementing IMetadataValidator.
     */
    function setValidator(uint32 keyType, uint8 metadataType, IMetadataValidator validator) external;

    /**
     * @notice Set the IdRegistry contract address. Only callable by owner.
     *
     * @param _idRegistry The new IdRegistry address.
     */
    function setIdRegistry(address _idRegistry) external;

    /**
     * @notice Set the KeyGateway address allowed to add keys. Only callable by owner.
     *
     * @param _keyGateway The new KeyGateway address.
     */
    function setKeyGateway(address _keyGateway) external;

    /**
     * @notice Permanently freeze the KeyGateway address. Only callable by owner.
     */
    function freezeKeyGateway() external;

    /**
     * @notice Set the maximum number of keys allowed per fid. Only callable by owner.
     *
     * @param _maxKeysPerFid The new max keys per fid.
     */
    function setMaxKeysPerFid(uint256 _maxKeysPerFid) external;
}

File 4 of 30 : IMetadataValidator.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

interface IMetadataValidator {
    /**
     * @notice Validate metadata associated with a key.
     *
     * @param userFid      The fid associated with the key.
     * @param key          Bytes of the key.
     * @param metadata     Metadata about the key.
     *
     * @return bool Whether the provided key and metadata are valid.
     */
    function validate(uint256 userFid, bytes memory key, bytes memory metadata) external returns (bool);
}

File 5 of 30 : IdRegistryLike.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

/**
 * @dev Minimal interface for IdRegistry, used by the KeyRegistry.
 */
interface IdRegistryLike {
    /*//////////////////////////////////////////////////////////////
                                 STORAGE
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Maps each address to an fid, or zero if it does not own an fid.
     */
    function idOf(address fidOwner) external view returns (uint256);

    /*//////////////////////////////////////////////////////////////
                                 VIEWS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Verify that a signature was produced by the custody address that owns an fid.
     *
     * @param custodyAddress   The address to check the signature of.
     * @param fid              The fid to check the signature of.
     * @param digest           The digest that was signed.
     * @param sig              The signature to check.
     *
     * @return isValid Whether provided signature is valid.
     */
    function verifyFidSignature(
        address custodyAddress,
        uint256 fid,
        bytes32 digest,
        bytes calldata sig
    ) external view returns (bool isValid);
}

File 6 of 30 : EIP712.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import {EIP712 as EIP712Base} from "openzeppelin/contracts/utils/cryptography/EIP712.sol";

import {IEIP712} from "../interfaces/abstract/IEIP712.sol";

abstract contract EIP712 is IEIP712, EIP712Base {
    constructor(string memory name, string memory version) EIP712Base(name, version) {}

    /*//////////////////////////////////////////////////////////////
                           EIP-712 HELPERS
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IEIP712
     */
    function domainSeparatorV4() external view returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @inheritdoc IEIP712
     */
    function hashTypedDataV4(bytes32 structHash) external view returns (bytes32) {
        return _hashTypedDataV4(structHash);
    }
}

File 7 of 30 : Migration.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import {Guardians} from "../abstract/Guardians.sol";
import {IMigration} from "../interfaces/abstract/IMigration.sol";

abstract contract Migration is IMigration, Guardians {
    /*//////////////////////////////////////////////////////////////
                              IMMUTABLES
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IMigration
     */
    uint24 public immutable gracePeriod;

    /*//////////////////////////////////////////////////////////////
                                STORAGE
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IMigration
     */
    address public migrator;

    /**
     * @inheritdoc IMigration
     */
    uint40 public migratedAt;

    /*//////////////////////////////////////////////////////////////
                                 MODIFIERS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Allow only the migrator to call the protected function.
     *         Revoke permissions after the migration period.
     */
    modifier onlyMigrator() {
        if (msg.sender != migrator) revert OnlyMigrator();
        if (isMigrated() && block.timestamp > migratedAt + gracePeriod) {
            revert PermissionRevoked();
        }
        _requirePaused();
        _;
    }

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set the grace period and migrator address.
     *         Pauses contract at deployment time.
     *
     * @param _gracePeriod  Migration grace period in seconds.
     * @param _initialOwner Initial owner address. Set as migrator.
     */
    constructor(uint24 _gracePeriod, address _migrator, address _initialOwner) Guardians(_initialOwner) {
        gracePeriod = _gracePeriod;
        migrator = _migrator;
        emit SetMigrator(address(0), _migrator);
        _pause();
    }

    /*//////////////////////////////////////////////////////////////
                                  VIEWS
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IMigration
     */
    function isMigrated() public view returns (bool) {
        return migratedAt != 0;
    }

    /*//////////////////////////////////////////////////////////////
                                MIGRATION
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IMigration
     */
    function migrate() external {
        if (msg.sender != migrator) revert OnlyMigrator();
        if (isMigrated()) revert AlreadyMigrated();
        _requirePaused();
        migratedAt = uint40(block.timestamp);
        emit Migrated(migratedAt);
    }

    /*//////////////////////////////////////////////////////////////
                              SET MIGRATOR
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IMigration
     */
    function setMigrator(address _migrator) public onlyOwner {
        if (isMigrated()) revert AlreadyMigrated();
        _requirePaused();
        emit SetMigrator(migrator, _migrator);
        migrator = _migrator;
    }
}

File 8 of 30 : Nonces.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import {Nonces as NoncesBase} from "openzeppelin-latest/contracts/utils/Nonces.sol";
import {INonces} from "../interfaces/abstract/INonces.sol";

abstract contract Nonces is INonces, NoncesBase {
    /*//////////////////////////////////////////////////////////////
                          NONCE MANAGEMENT
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc INonces
     */
    function useNonce() external returns (uint256) {
        return _useNonce(msg.sender);
    }
}

File 9 of 30 : Signatures.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import {SignatureChecker} from "openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {ISignatures} from "../interfaces/abstract/ISignatures.sol";

abstract contract Signatures is ISignatures {
    /*//////////////////////////////////////////////////////////////
                     SIGNATURE VERIFICATION HELPERS
    //////////////////////////////////////////////////////////////*/

    function _verifySig(bytes32 digest, address signer, uint256 deadline, bytes memory sig) internal view {
        if (block.timestamp > deadline) revert SignatureExpired();
        if (!SignatureChecker.isValidSignatureNow(signer, digest, sig)) {
            revert InvalidSignature();
        }
    }
}

File 10 of 30 : EnumerableKeySet.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

struct KeySet {
    // Storage of set values
    bytes[] _values;
    // Position of the value in the `values` array, plus 1 because index 0
    // means a value is not in the set.
    mapping(bytes => uint256) _indexes;
}

/**
 * @dev Modified from OpenZeppelin v4.9.3 EnumerableSet
 */
library EnumerableKeySet {
    /**
     * @dev Add a key to the set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(KeySet storage set, bytes calldata value) internal returns (bool) {
        if (!contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a key from the set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(KeySet storage set, bytes calldata value) internal returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes memory lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(KeySet storage set, bytes calldata value) internal view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(KeySet storage set) internal view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(KeySet storage set, uint256 index) internal view returns (bytes memory) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(KeySet storage set) internal view returns (bytes[] memory) {
        return set._values;
    }
}

File 11 of 30 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

File 12 of 30 : EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.8;

import "./ECDSA.sol";
import "../ShortStrings.sol";
import "../../interfaces/IERC5267.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 *
 * _Available since v3.4._
 *
 * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
 */
abstract contract EIP712 is IERC5267 {
    using ShortStrings for *;

    bytes32 private constant _TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _cachedDomainSeparator;
    uint256 private immutable _cachedChainId;
    address private immutable _cachedThis;

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

    ShortString private immutable _name;
    ShortString private immutable _version;
    string private _nameFallback;
    string private _versionFallback;

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        _name = name.toShortStringWithFallback(_nameFallback);
        _version = version.toShortStringWithFallback(_versionFallback);
        _hashedName = keccak256(bytes(name));
        _hashedVersion = keccak256(bytes(version));

        _cachedChainId = block.chainid;
        _cachedDomainSeparator = _buildDomainSeparator();
        _cachedThis = address(this);
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev See {EIP-5267}.
     *
     * _Available since v4.9._
     */
    function eip712Domain()
        public
        view
        virtual
        override
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _name.toStringWithFallback(_nameFallback),
            _version.toStringWithFallback(_versionFallback),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }
}

File 13 of 30 : IEIP712.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface IEIP712 {
    /*//////////////////////////////////////////////////////////////
                           EIP-712 HELPERS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Helper view to read EIP-712 domain separator.
     *
     * @return bytes32 domain separator hash.
     */
    function domainSeparatorV4() external view returns (bytes32);

    /**
     * @notice Helper view to hash EIP-712 typed data onchain.
     *
     * @param structHash EIP-712 typed data hash.
     *
     * @return bytes32 EIP-712 message digest.
     */
    function hashTypedDataV4(bytes32 structHash) external view returns (bytes32);
}

File 14 of 30 : Guardians.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import {Ownable2Step} from "openzeppelin/contracts/access/Ownable2Step.sol";
import {Pausable} from "openzeppelin/contracts/security/Pausable.sol";

import {IGuardians} from "../interfaces/abstract/IGuardians.sol";

abstract contract Guardians is IGuardians, Ownable2Step, Pausable {
    /**
     * @notice Mapping of addresses to guardian status.
     */
    mapping(address guardian => bool isGuardian) public guardians;

    /*//////////////////////////////////////////////////////////////
                               MODIFIERS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Allow only the owner or a guardian to call the
     *         protected function.
     */
    modifier onlyGuardian() {
        if (msg.sender != owner() && !guardians[msg.sender]) {
            revert OnlyGuardian();
        }
        _;
    }

    /*//////////////////////////////////////////////////////////////
                             CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set the initial owner address.
     *
     * @param _initialOwner Address of the contract owner.
     */
    constructor(address _initialOwner) {
        _transferOwnership(_initialOwner);
    }

    /*//////////////////////////////////////////////////////////////
                         PERMISSIONED FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc IGuardians
     */
    function addGuardian(address guardian) external onlyOwner {
        guardians[guardian] = true;
        emit Add(guardian);
    }

    /**
     * @inheritdoc IGuardians
     */
    function removeGuardian(address guardian) external onlyOwner {
        guardians[guardian] = false;
        emit Remove(guardian);
    }

    /**
     * @inheritdoc IGuardians
     */
    function pause() external onlyGuardian {
        _pause();
    }

    /**
     * @inheritdoc IGuardians
     */
    function unpause() external onlyOwner {
        _unpause();
    }
}

File 15 of 30 : IMigration.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface IMigration {
    /*//////////////////////////////////////////////////////////////
                                 ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @dev Revert if the caller is not the migrator.
    error OnlyMigrator();

    /// @dev Revert if the migrator calls a migration function after the grace period.
    error PermissionRevoked();

    /// @dev Revert if the migrator calls migrate more than once.
    error AlreadyMigrated();

    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    /**
     * @dev Emit an event when the admin calls migrate(). Used to migrate
     *      Hubs from reading events from one contract to another.
     *
     * @param migratedAt  The timestamp at which the migration occurred.
     */
    event Migrated(uint256 indexed migratedAt);

    /**
     * @notice Emit an event when the owner changes the migrator address.
     *
     * @param oldMigrator The address of the previous migrator.
     * @param newMigrator The address of the new migrator.
     */
    event SetMigrator(address oldMigrator, address newMigrator);

    /*//////////////////////////////////////////////////////////////
                              IMMUTABLES
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Period in seconds after migration during which admin can continue to call protected
     *         migration functions. Admins can make corrections to the migrated data during the
     *         grace period if necessary, but cannot make changes after it expires.
     */
    function gracePeriod() external view returns (uint24);

    /*//////////////////////////////////////////////////////////////
                               STORAGE
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Migration admin address.
     */
    function migrator() external view returns (address);

    /**
     * @notice Timestamp at which data is migrated. Hubs will cut over to use this contract as their
     *         source of truth after this timestamp.
     */
    function migratedAt() external view returns (uint40);

    /*//////////////////////////////////////////////////////////////
                                  VIEWS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Check if the contract has been migrated.
     *
     * @return true if the contract has been migrated, false otherwise.
     */
    function isMigrated() external view returns (bool);

    /*//////////////////////////////////////////////////////////////
                         PERMISSIONED ACTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set the time of the migration and emit an event. Hubs will watch this event and
     *         cut over to use this contract as their source of truth after this timestamp.
     *         Only callable by the migrator.
     */
    function migrate() external;

    /**
     * @notice Set the migrator address. Only callable by owner.
     *
     * @param _migrator Migrator address.
     */
    function setMigrator(address _migrator) external;
}

File 16 of 30 : Nonces.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/**
 * @dev Provides tracking nonces for addresses. Nonces will only increment.
 */
abstract contract Nonces {
    /**
     * @dev The nonce used for an `account` is not the expected current nonce.
     */
    error InvalidAccountNonce(address account, uint256 currentNonce);

    mapping(address => uint256) private _nonces;

    /**
     * @dev Returns an the next unused nonce for an address.
     */
    function nonces(address owner) public view virtual returns (uint256) {
        return _nonces[owner];
    }

    /**
     * @dev Consumes a nonce.
     *
     * Returns the current value and increments nonce.
     */
    function _useNonce(address owner) internal virtual returns (uint256) {
        // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be
        // decremented or reset. This guarantees that the nonce never overflows.
        unchecked {
            // It is important to do x++ and not ++x here.
            return _nonces[owner]++;
        }
    }

    /**
     * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
     */
    function _useCheckedNonce(address owner, uint256 nonce) internal virtual returns (uint256) {
        uint256 current = _useNonce(owner);
        if (nonce != current) {
            revert InvalidAccountNonce(owner, current);
        }
        return current;
    }
}

File 17 of 30 : INonces.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface INonces {
    /*//////////////////////////////////////////////////////////////
                          NONCE MANAGEMENT
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Increase caller's nonce, invalidating previous signatures.
     *
     * @return uint256 The caller's new nonce.
     */
    function useNonce() external returns (uint256);
}

File 18 of 30 : SignatureChecker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";
import "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like
 * Argent and Gnosis Safe.
 *
 * _Available since v4.1._
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
        return
            (error == ECDSA.RecoverError.NoError && recovered == signer) ||
            isValidERC1271SignatureNow(signer, hash, signature);
    }

    /**
     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
     * against the signer smart contract using ERC1271.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidERC1271SignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
        );
        return (success &&
            result.length >= 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

File 19 of 30 : ISignatures.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface ISignatures {
    /*//////////////////////////////////////////////////////////////
                                 ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @dev Revert when the signature provided is invalid.
    error InvalidSignature();

    /// @dev Revert when the block.timestamp is ahead of the signature deadline.
    error SignatureExpired();
}

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

pragma solidity ^0.8.0;

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

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

File 21 of 30 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}

File 22 of 30 : ShortStrings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.8;

import "./StorageSlot.sol";

// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |
// | length  | 0x                                                              BB |
type ShortString is bytes32;

/**
 * @dev This library provides functions to convert short memory strings
 * into a `ShortString` type that can be used as an immutable variable.
 *
 * Strings of arbitrary length can be optimized using this library if
 * they are short enough (up to 31 bytes) by packing them with their
 * length (1 byte) in a single EVM word (32 bytes). Additionally, a
 * fallback mechanism can be used for every other case.
 *
 * Usage example:
 *
 * ```solidity
 * contract Named {
 *     using ShortStrings for *;
 *
 *     ShortString private immutable _name;
 *     string private _nameFallback;
 *
 *     constructor(string memory contractName) {
 *         _name = contractName.toShortStringWithFallback(_nameFallback);
 *     }
 *
 *     function name() external view returns (string memory) {
 *         return _name.toStringWithFallback(_nameFallback);
 *     }
 * }
 * ```
 */
library ShortStrings {
    // Used as an identifier for strings longer than 31 bytes.
    bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;

    error StringTooLong(string str);
    error InvalidShortString();

    /**
     * @dev Encode a string of at most 31 chars into a `ShortString`.
     *
     * This will trigger a `StringTooLong` error is the input string is too long.
     */
    function toShortString(string memory str) internal pure returns (ShortString) {
        bytes memory bstr = bytes(str);
        if (bstr.length > 31) {
            revert StringTooLong(str);
        }
        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
    }

    /**
     * @dev Decode a `ShortString` back to a "normal" string.
     */
    function toString(ShortString sstr) internal pure returns (string memory) {
        uint256 len = byteLength(sstr);
        // using `new string(len)` would work locally but is not memory safe.
        string memory str = new string(32);
        /// @solidity memory-safe-assembly
        assembly {
            mstore(str, len)
            mstore(add(str, 0x20), sstr)
        }
        return str;
    }

    /**
     * @dev Return the length of a `ShortString`.
     */
    function byteLength(ShortString sstr) internal pure returns (uint256) {
        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
        if (result > 31) {
            revert InvalidShortString();
        }
        return result;
    }

    /**
     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
     */
    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
        if (bytes(value).length < 32) {
            return toShortString(value);
        } else {
            StorageSlot.getStringSlot(store).value = value;
            return ShortString.wrap(_FALLBACK_SENTINEL);
        }
    }

    /**
     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     */
    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return toString(value);
        } else {
            return store;
        }
    }

    /**
     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     *
     * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
     */
    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return byteLength(value);
        } else {
            return bytes(store).length;
        }
    }
}

File 23 of 30 : IERC5267.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.0;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}

File 24 of 30 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

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

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

File 25 of 30 : IGuardians.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface IGuardians {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    /**
     * @dev Emit an event when owner adds a new guardian address.
     *
     * @param guardian Address of the added guardian.
     */
    event Add(address indexed guardian);

    /**
     * @dev Emit an event when owner removes a guardian address.
     *
     * @param guardian Address of the removed guardian.
     */
    event Remove(address indexed guardian);

    /*//////////////////////////////////////////////////////////////
                                 ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @dev Revert if an unauthorized caller calls a protected function.
    error OnlyGuardian();

    /*//////////////////////////////////////////////////////////////
                         PERMISSIONED FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Add an address as a guardian. Only callable by owner.
     *
     * @param guardian Address of the guardian.
     */
    function addGuardian(address guardian) external;

    /**
     * @notice Remove a guardian. Only callable by owner.
     *
     * @param guardian Address of the guardian.
     */
    function removeGuardian(address guardian) external;

    /**
     * @notice Pause the contract. Only callable by owner or a guardian.
     */
    function pause() external;

    /**
     * @notice Unpause the contract. Only callable by owner.
     */
    function unpause() external;
}

File 26 of 30 : IERC1271.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

File 27 of 30 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

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

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

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

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

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

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

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 28 of 30 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

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:
 * ```solidity
 * 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`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes 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
        }
    }

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

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

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

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

File 29 of 30 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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 256, 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 << 3) < value ? 1 : 0);
        }
    }
}

File 30 of 30 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

Settings
{
  "remappings": [
    "solmate/=lib/solmate/",
    "openzeppelin/=lib/openzeppelin-contracts/",
    "openzeppelin-latest/=lib/openzeppelin-latest/",
    "chainlink/=lib/chainlink-brownie-contracts/contracts/src/",
    "chainlink-brownie-contracts/=lib/chainlink-brownie-contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-latest/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 100000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "none",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_idRegistry","type":"address"},{"internalType":"address","name":"_migrator","type":"address"},{"internalType":"address","name":"_initialOwner","type":"address"},{"internalType":"uint256","name":"_maxKeysPerFid","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyMigrated","type":"error"},{"inputs":[],"name":"ExceedsMaximum","type":"error"},{"inputs":[],"name":"GatewayFrozen","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidKeyType","type":"error"},{"inputs":[],"name":"InvalidMaxKeys","type":"error"},{"inputs":[],"name":"InvalidMetadata","type":"error"},{"inputs":[],"name":"InvalidMetadataType","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidState","type":"error"},{"inputs":[],"name":"OnlyGuardian","type":"error"},{"inputs":[],"name":"OnlyMigrator","type":"error"},{"inputs":[],"name":"PermissionRevoked","type":"error"},{"inputs":[],"name":"SignatureExpired","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[{"internalType":"uint32","name":"keyType","type":"uint32"},{"internalType":"uint8","name":"metadataType","type":"uint8"}],"name":"ValidatorNotFound","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fid","type":"uint256"},{"indexed":true,"internalType":"uint32","name":"keyType","type":"uint32"},{"indexed":true,"internalType":"bytes","name":"key","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"keyBytes","type":"bytes"},{"indexed":false,"internalType":"uint8","name":"metadataType","type":"uint8"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"Add","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"guardian","type":"address"}],"name":"Add","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fid","type":"uint256"},{"indexed":true,"internalType":"bytes","name":"key","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"keyBytes","type":"bytes"}],"name":"AdminReset","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"keyGateway","type":"address"}],"name":"FreezeKeyGateway","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"migratedAt","type":"uint256"}],"name":"Migrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fid","type":"uint256"},{"indexed":true,"internalType":"bytes","name":"key","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"keyBytes","type":"bytes"}],"name":"Remove","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"guardian","type":"address"}],"name":"Remove","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldIdRegistry","type":"address"},{"indexed":false,"internalType":"address","name":"newIdRegistry","type":"address"}],"name":"SetIdRegistry","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldKeyGateway","type":"address"},{"indexed":false,"internalType":"address","name":"newKeyGateway","type":"address"}],"name":"SetKeyGateway","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMax","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMax","type":"uint256"}],"name":"SetMaxKeysPerFid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldMigrator","type":"address"},{"indexed":false,"internalType":"address","name":"newMigrator","type":"address"}],"name":"SetMigrator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"keyType","type":"uint32"},{"indexed":false,"internalType":"uint8","name":"metadataType","type":"uint8"},{"indexed":false,"internalType":"address","name":"oldValidator","type":"address"},{"indexed":false,"internalType":"address","name":"newValidator","type":"address"}],"name":"SetValidator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"REMOVE_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fidOwner","type":"address"},{"internalType":"uint32","name":"keyType","type":"uint32"},{"internalType":"bytes","name":"key","type":"bytes"},{"internalType":"uint8","name":"metadataType","type":"uint8"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"guardian","type":"address"}],"name":"addGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"fid","type":"uint256"},{"components":[{"internalType":"bytes","name":"key","type":"bytes"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"internalType":"struct IKeyRegistry.BulkAddKey[]","name":"keys","type":"tuple[]"}],"internalType":"struct IKeyRegistry.BulkAddData[]","name":"items","type":"tuple[]"}],"name":"bulkAddKeysForMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"fid","type":"uint256"},{"internalType":"bytes[]","name":"keys","type":"bytes[]"}],"internalType":"struct IKeyRegistry.BulkResetData[]","name":"items","type":"tuple[]"}],"name":"bulkResetKeysForMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"domainSeparatorV4","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"freezeKeyGateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gatewayFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gracePeriod","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"guardian","type":"address"}],"name":"guardians","outputs":[{"internalType":"bool","name":"isGuardian","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"structHash","type":"bytes32"}],"name":"hashTypedDataV4","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"idRegistry","outputs":[{"internalType":"contract IdRegistryLike","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMigrated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fid","type":"uint256"},{"internalType":"enum IKeyRegistry.KeyState","name":"state","type":"uint8"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"keyAt","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fid","type":"uint256"},{"internalType":"bytes","name":"key","type":"bytes"}],"name":"keyDataOf","outputs":[{"components":[{"internalType":"enum IKeyRegistry.KeyState","name":"state","type":"uint8"},{"internalType":"uint32","name":"keyType","type":"uint32"}],"internalType":"struct IKeyRegistry.KeyData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keyGateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fid","type":"uint256"},{"internalType":"bytes","name":"key","type":"bytes"}],"name":"keys","outputs":[{"internalType":"enum IKeyRegistry.KeyState","name":"state","type":"uint8"},{"internalType":"uint32","name":"keyType","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fid","type":"uint256"},{"internalType":"enum IKeyRegistry.KeyState","name":"state","type":"uint8"}],"name":"keysOf","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fid","type":"uint256"},{"internalType":"enum IKeyRegistry.KeyState","name":"state","type":"uint8"},{"internalType":"uint256","name":"startIdx","type":"uint256"},{"internalType":"uint256","name":"batchSize","type":"uint256"}],"name":"keysOf","outputs":[{"internalType":"bytes[]","name":"page","type":"bytes[]"},{"internalType":"uint256","name":"nextIdx","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxKeysPerFid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"migratedAt","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"key","type":"bytes"}],"name":"remove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fidOwner","type":"address"},{"internalType":"bytes","name":"key","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"sig","type":"bytes"}],"name":"removeFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"guardian","type":"address"}],"name":"removeGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_idRegistry","type":"address"}],"name":"setIdRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_keyGateway","type":"address"}],"name":"setKeyGateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxKeysPerFid","type":"uint256"}],"name":"setMaxKeysPerFid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_migrator","type":"address"}],"name":"setMigrator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"keyType","type":"uint32"},{"internalType":"uint8","name":"metadataType","type":"uint8"},{"internalType":"contract IMetadataValidator","name":"validator","type":"address"}],"name":"setValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fid","type":"uint256"},{"internalType":"enum IKeyRegistry.KeyState","name":"state","type":"uint8"}],"name":"totalKeys","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"useNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"keyType","type":"uint32"},{"internalType":"uint8","name":"metadataType","type":"uint8"}],"name":"validators","outputs":[{"internalType":"contract IMetadataValidator","name":"validator","type":"address"}],"stateMutability":"view","type":"function"}]

6101806040523480156200001257600080fd5b506040516200435b3803806200435b833981016040819052620000359162000457565b6040518060400160405280601581526020017f466172636173746572204b657952656769737472790000000000000000000000815250604051806040016040528060018152602001603160f81b815250818162015180878780620000a8620000a26200028d60201b60201c565b62000291565b6001805460ff60a01b19169055620000c08162000291565b5062ffffff8316608052600380546001600160a01b0319166001600160a01b038416908117909155604080516000815260208101929092527fd8ad954fe808212ab9ed7139873e40807dff7995fe36e3d6cdeb8fa00fcebf10910160405180910390a16200012d620002af565b506200013f9150839050600462000312565b610140526200015081600562000312565b61016052815160208084019190912061010052815190820120610120524660c052620001e06101005161012051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60a05250503060e0525050600780546001600160a01b0319166001600160a01b0386169081179091556009829055604080516000815260208101929092527f940dcf34ec2e245e837ee4599997e577ce274d7b87c73238e2878ac7ea1af2f1910160405180910390a16040805160008152602081018390527f6c336d0e5e74bb26a5e2d4646801801837b0fdbaddd9131923fd42d740449731910160405180910390a1505050506200068f565b3390565b600180546001600160a01b0319169055620002ac816200034b565b50565b620002b96200039b565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620002f53390565b6040516001600160a01b03909116815260200160405180910390a1565b600060208351101562000332576200032a83620003f7565b905062000345565b816200033f84826200054e565b5060ff90505b92915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b620003af600154600160a01b900460ff1690565b15620003f55760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064015b60405180910390fd5b565b600080829050601f8151111562000425578260405163305a27a960e01b8152600401620003ec91906200061a565b805162000432826200066a565b179392505050565b80516001600160a01b03811681146200045257600080fd5b919050565b600080600080608085870312156200046e57600080fd5b62000479856200043a565b935062000489602086016200043a565b925062000499604086016200043a565b6060959095015193969295505050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620004d457607f821691505b602082108103620004f557634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200054957600081815260208120601f850160051c81016020861015620005245750805b601f850160051c820191505b81811015620005455782815560010162000530565b5050505b505050565b81516001600160401b038111156200056a576200056a620004a9565b62000582816200057b8454620004bf565b84620004fb565b602080601f831160018114620005ba5760008415620005a15750858301515b600019600386901b1c1916600185901b17855562000545565b600085815260208120601f198616915b82811015620005eb57888601518255948401946001909101908401620005ca565b50858210156200060a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083528351808285015260005b8181101562000649578581018301518582016040015282016200062b565b506000604082860101526040601f19601f8301168501019250505092915050565b80516020808301519190811015620004f55760001960209190910360031b1b16919050565b60805160a05160c05160e05161010051610120516101405161016051613c5862000703600039600061132e01526000611303015260006125950152600061256d015260006124c8015260006124f20152600061251c01526000818161068c01528181610c040152610ee30152613c586000f3fe608060405234801561001057600080fd5b50600436106102ff5760003560e01c80637cd07e471161019c578063a526d83b116100ee578063d881039511610097578063f27995e311610071578063f27995e3146107d3578063f2fde38b146107f4578063ffa1ad741461080757600080fd5b8063d88103951461076b578063e30c3978146107ac578063e33acf38146107ca57600080fd5b8063b221dac4116100c8578063b221dac41461071e578063b577556114610731578063d4c048091461075857600080fd5b8063a526d83b146106c2578063ac34cc5a146106d5578063b06faf62146106f557600080fd5b806384b0196e116101505780638fd3ab801161012a5780638fd3ab801461065a57806395e7549f14610662578063a06db7dc1461068757600080fd5b806384b0196e146105e25780638b21e484146105fd5780638da5cb5b1461063c57600080fd5b8063803347371161018157806380334737146105a757806381749468146105c75780638456cb59146105da57600080fd5b80637cd07e47146105515780637ecebe001461057157600080fd5b80634980f28811610255578063708e9c7011610209578063787bd966116101e3578063787bd9661461052e57806378e890ba1461054157806379ba50971461054957600080fd5b8063708e9c70146105005780637140415614610513578063715018a61461052657600080fd5b80635c975abb1161023a5780635c975abb146104ad5780636840b75e146104d057806369615a4c146104e357600080fd5b80634980f2881461047957806358edef4c1461049a57600080fd5b8063207e3d69116102b75780633f4ba83a116102915780633f4ba83a1461045657806346b3f4291461045e57806347cf8d4d1461047157600080fd5b8063207e3d691461041b57806323cf311814610430578063368ab6101461044357600080fd5b80630e24e34c116102e85780630e24e34c146103815780630ea9442c146103db5780631f64222f146103fb57600080fd5b80630633b14a146103045780630aa13b8c1461033c575b600080fd5b610327610312366004612ead565b60026020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b60075461035c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610333565b6103cd61038f366004612ef9565b600c602090815260009283526040909220815180830184018051928152908401929093019190912091525460ff811690610100900463ffffffff1682565b60405161033392919061303c565b6103ee6103e936600461306c565b610843565b604051610333919061310f565b61040e610409366004613122565b610863565b60405161033391906131a3565b61042e61042936600461321d565b610880565b005b61042e61043e366004612ead565b6108f9565b61042e6104513660046132c4565b6109fd565b61042e610b6d565b61042e61046c366004613350565b610b7f565b61042e610d31565b61048c610487366004613392565b610e1c565b604051908152602001610333565b61042e6104a83660046133ab565b610e27565b60015474010000000000000000000000000000000000000000900460ff16610327565b61048c6104de366004613122565b610e46565b33600090815260066020526040902080546001810190915561048c565b61042e61050e366004613350565b610e5e565b61042e610521366004612ead565b611058565b61042e6110d4565b61042e61053c3660046133e1565b6110e6565b61048c611117565b61042e611121565b60035461035c9073ffffffffffffffffffffffffffffffffffffffff1681565b61048c61057f366004612ead565b73ffffffffffffffffffffffffffffffffffffffff1660009081526006602052604090205490565b60085461035c9073ffffffffffffffffffffffffffffffffffffffff1681565b61042e6105d5366004612ead565b6111db565b61042e61127e565b6105ea6112f5565b604051610333979695949392919061346d565b6003546106269074010000000000000000000000000000000000000000900464ffffffffff1681565b60405164ffffffffff9091168152602001610333565b60005473ffffffffffffffffffffffffffffffffffffffff1661035c565b61042e61139a565b6008546103279074010000000000000000000000000000000000000000900460ff1681565b6106ae7f000000000000000000000000000000000000000000000000000000000000000081565b60405162ffffff9091168152602001610333565b61042e6106d0366004612ead565b6114cb565b6106e86106e336600461352c565b61154a565b6040516103339190613578565b60035474010000000000000000000000000000000000000000900464ffffffffff161515610327565b61042e61072c366004612ead565b6115d9565b61048c7f32e091a0c6fc95c826855f4e40ebda4957b528bd84c9062416ceb903082dabe481565b61042e610766366004613392565b6116d1565b61035c61077936600461359f565b600d60209081526000928352604080842090915290825290205473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1661035c565b61048c60095481565b6107e66107e13660046135c9565b611755565b604051610333929190613604565b61042e610802366004612ead565b611898565b6103ee6040518060400160405280600a81526020017f323032332e31312e31350000000000000000000000000000000000000000000081525081565b6060610859826108538686611948565b906119d6565b90505b9392505050565b60606108776108728484611948565b611a88565b90505b92915050565b610888611b65565b60085473ffffffffffffffffffffffffffffffffffffffff1633146108d9576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108f06108e588611bea565b878787878787611cc0565b50505050505050565b610901611cd1565b60035474010000000000000000000000000000000000000000900464ffffffffff161561095a576040517fca1c3cbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610962611d52565b6003546040805173ffffffffffffffffffffffffffffffffffffffff928316815291831660208301527fd8ad954fe808212ab9ed7139873e40807dff7995fe36e3d6cdeb8fa00fcebf10910160405180910390a1600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b610a05611cd1565b8263ffffffff16600003610a45576040517f36dccb4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8160ff16600003610a82576040517f5110099800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff83166000818152600d6020908152604080832060ff8716808552908352928190205481519485529184019290925273ffffffffffffffffffffffffffffffffffffffff9081168383015283166060830152517fd964242236f6208120d76a25cd886db49c82403f50d88dfd1bc865ee60ad462d9181900360800190a163ffffffff9092166000908152600d6020908152604080832060ff909416835292905220805473ffffffffffffffffffffffffffffffffffffffff9092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909216919091179055565b610b75611cd1565b610b7d611dd6565b565b60035473ffffffffffffffffffffffffffffffffffffffff163314610bd0576040517f8020644900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035474010000000000000000000000000000000000000000900464ffffffffff1615158015610c575750600354610c4d907f000000000000000000000000000000000000000000000000000000000000000062ffffff169074010000000000000000000000000000000000000000900464ffffffffff16613655565b64ffffffffff1642115b15610c8e576040517fca0dc97b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c96611d52565b60005b81811015610d2c5736838383818110610cb457610cb461367a565b9050602002810190610cc691906136a9565b905060005b610cd860208301836136e7565b9050811015610d2257610d1a8235610cf360208501856136e7565b84818110610d0357610d0361367a565b9050602002810190610d15919061374f565b611e53565b600101610ccb565b5050600101610c99565b505050565b610d39611cd1565b60085474010000000000000000000000000000000000000000900460ff1615610d8e576040517f351f92c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60085460405173ffffffffffffffffffffffffffffffffffffffff90911681527fcb685c7ba5a65fe9e6be9b7decbb5dc8ebba92bcae3cb09fc2a5a075b1eb57729060200160405180910390a1600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b600061087a82611f5a565b610e2f611b65565b610e42610e3b33611bea565b8383611fa2565b5050565b6000610877610e558484611948565b5490565b905090565b60035473ffffffffffffffffffffffffffffffffffffffff163314610eaf576040517f8020644900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035474010000000000000000000000000000000000000000900464ffffffffff1615158015610f365750600354610f2c907f000000000000000000000000000000000000000000000000000000000000000062ffffff169074010000000000000000000000000000000000000000900464ffffffffff16613655565b64ffffffffff1642115b15610f6d576040517fca0dc97b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610f75611d52565b60005b81811015610d2c5736838383818110610f9357610f9361367a565b9050602002810190610fa591906136a9565b905060005b610fb760208301836136e7565b905081101561104e5761104682356001610fd460208601866136e7565b85818110610fe457610fe461367a565b9050602002810190610ff691906136a9565b611000908061374f565b600161100f60208901896136e7565b8881811061101f5761101f61367a565b905060200281019061103191906136a9565b61103f90602081019061374f565b600061209e565b600101610faa565b5050600101610f78565b611060611cd1565b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055517fbe7c7ac3248df4581c206a84aab3cb4e7d521b5398b42b681757f78a5a7d411e9190a250565b6110dc611cd1565b610b7d6000612371565b6110ee611b65565b6110fc8686868686866123a2565b61110f61110887611bea565b8686611fa2565b505050505050565b6000610e596124ae565b600154339073ffffffffffffffffffffffffffffffffffffffff1681146111cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e6572000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6111d881612371565b50565b6111e3611cd1565b6007546040805173ffffffffffffffffffffffffffffffffffffffff928316815291831660208301527f940dcf34ec2e245e837ee4599997e577ce274d7b87c73238e2878ac7ea1af2f1910160405180910390a1600780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633148015906112b657503360009081526002602052604090205460ff16155b156112ed576040517fcae1d95600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b7d6125e6565b6000606080828080836113297f00000000000000000000000000000000000000000000000000000000000000006004612655565b6113547f00000000000000000000000000000000000000000000000000000000000000006005612655565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b60035473ffffffffffffffffffffffffffffffffffffffff1633146113eb576040517f8020644900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035474010000000000000000000000000000000000000000900464ffffffffff1615611444576040517fca1c3cbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61144c611d52565b600380547fffffffffffffff0000000000ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000004264ffffffffff90811682029290921792839055604051920416907fe4a25c0c2cbe89d6ad8b64c61a7dbdd20d1f781f6023f1ab94ebb7fe0aef6ab890600090a2565b6114d3611cd1565b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055517f87dc5eecd6d6bdeae407c426da6bfba5b7190befc554ed5d4d62dd5cf939fbae9190a250565b60408051808201909152600080825260208201526000848152600c602052604090819020905161157d90859085906137b4565b908152604080519182900360200182208282019091528054829060ff1660028111156115ab576115ab612fd2565b60028111156115bc576115bc612fd2565b81529054610100900463ffffffff16602090910152949350505050565b6115e1611cd1565b60085474010000000000000000000000000000000000000000900460ff1615611636576040517f351f92c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6008546040805173ffffffffffffffffffffffffffffffffffffffff928316815291831660208301527f56785750704201befc0a27dae1e5d37835a8ad6e35affc87136ed24d1ac694ac910160405180910390a1600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6116d9611cd1565b6009548111611714576040517fc5ce0d9800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60095460408051918252602082018390527f6c336d0e5e74bb26a5e2d4646801801837b0fdbaddd9131923fd42d740449731910160405180910390a1600955565b60606000806117648787611948565b90506000611770825490565b90508086106117b25760408051600080825260208201909252906117a4565b606081526020019060019003908161178f5790505b50600093509350505061188f565b60006117be87836137c4565b905060008682106117cf57866117d1565b815b90508067ffffffffffffffff8111156117ec576117ec612eca565b60405190808252806020026020018201604052801561181f57816020015b606081526020019060019003908161180a5790505b50955060005b818110156118715761184161183a828b6137d7565b86906119d6565b8782815181106118535761185361367a565b60200260200101819052508080611869906137ea565b915050611825565b5061187c81896137d7565b945082851061188a57600094505b505050505b94509492505050565b6118a0611cd1565b6001805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915561190360005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000600182600281111561195e5761195e612fd2565b0361197757506000828152600a6020526040902061087a565b600282600281111561198b5761198b612fd2565b036119a457506000828152600b6020526040902061087a565b6040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60608260000182815481106119ed576119ed61367a565b906000526020600020018054611a0290613822565b80601f0160208091040260200160405190810160405280929190818152602001828054611a2e90613822565b8015611a7b5780601f10611a5057610100808354040283529160200191611a7b565b820191906000526020600020905b815481529060010190602001808311611a5e57829003601f168201915b5050505050905092915050565b606081600001805480602002602001604051908101604052809291908181526020016000905b82821015611b5a578382906000526020600020018054611acd90613822565b80601f0160208091040260200160405190810160405280929190818152602001828054611af990613822565b8015611b465780601f10611b1b57610100808354040283529160200191611b46565b820191906000526020600020905b815481529060010190602001808311611b2957829003601f168201915b505050505081526020019060010190611aae565b505050509050919050565b60015474010000000000000000000000000000000000000000900460ff1615610b7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016111c6565b6007546040517fd94fe83200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152600092169063d94fe83290602401602060405180830381865afa158015611c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7f9190613875565b905080600003611cbb576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6108f087878787878787600161209e565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016111c6565b60015474010000000000000000000000000000000000000000900460ff16610b7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016111c6565b611dde611d52565b600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b6000838152600c60205260408082209051611e7190859085906137b4565b90815260405190819003602001902090506001815460ff166002811115611e9a57611e9a612fd2565b14611ed1576040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611edc848484612700565b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000168155604051611f1290849084906137b4565b6040518091039020847f1ecc1009ebad5d2fb61239462f4f9f6f152662defe1845fc87f07d96bd1c60b48585604051611f4c9291906138d7565b60405180910390a350505050565b600061087a611f676124ae565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b6000838152600c60205260408082209051611fc090859085906137b4565b90815260405190819003602001902090506001815460ff166002811115611fe957611fe9612fd2565b14612020576040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61202b84848461271f565b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600217815560405161206490849084906137b4565b6040518091039020847f09e77066e0155f46785be12f6938a6b2e4be4381e59058129ce15f355cb969588585604051611f4c9291906138d7565b6000888152600c602052604080822090516120bc90899089906137b4565b90815260405190819003602001902090506000815460ff1660028111156120e5576120e5612fd2565b1461211c576040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60095461212a8a6001610e46565b10612161576040517f2926404200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff88166000908152600d6020908152604080832060ff8916845290915290205473ffffffffffffffffffffffffffffffffffffffff16806121e3576040517fb736f27f00000000000000000000000000000000000000000000000000000000815263ffffffff8a16600482015260ff871660248201526044016111c6565b6121ee8a8989612752565b815463ffffffff8a16610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000090911617600117825560405161223590899089906137b4565b60405180910390208963ffffffff168b7f7d285df41058466977811345cd453c0c52e8d841ffaabc74fc050f277ad4de028b8b8b8b8b60405161227c9594939291906138eb565b60405180910390a48215612365576040517faa4e0ce800000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff83169063aa4e0ce8906122e7908e908d908d908c908c90600401613927565b6020604051808303816000875af1158015612306573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232a9190613954565b905080612363576040517fbcecb64a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b50505050505050505050565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556111d88161276b565b61110f6124707f32e091a0c6fc95c826855f4e40ebda4957b528bd84c9062416ceb903082dabe48888886040516123da9291906137b4565b60405180910390206124168b73ffffffffffffffffffffffffffffffffffffffff16600090815260066020526040902080546001810190915590565b60408051602081019590955273ffffffffffffffffffffffffffffffffffffffff909316928401929092526060830152608082015260a0810186905260c00160405160208183030381529060405280519060200120611f5a565b878585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506127e092505050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614801561251457507f000000000000000000000000000000000000000000000000000000000000000046145b1561253e57507f000000000000000000000000000000000000000000000000000000000000000090565b610e59604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6125ee611b65565b600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e293390565b606060ff831461266f576126688361285b565b905061087a565b81805461267b90613822565b80601f01602080910402602001604051908101604052809291908181526020018280546126a790613822565b80156126f45780601f106126c9576101008083540402835291602001916126f4565b820191906000526020600020905b8154815290600101906020018083116126d757829003601f168201915b5050505050905061087a565b6000838152600a6020526040902061271990838361289a565b50505050565b6000838152600a6020526040902061273890838361289a565b506000838152600b60205260409020612719908383612a5d565b6000838152600a60205260409020612719908383612a5d565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8142111561281a576040517f0819bdcd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612825838583612ac3565b612719576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060600061286883612b3e565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b6000808460010184846040516128b19291906137b4565b908152602001604051809103902054905080600014612a535760006128d76001836137c4565b86549091506000906128eb906001906137c4565b90508181146129f257600087600001828154811061290b5761290b61367a565b90600052602060002001805461292090613822565b80601f016020809104026020016040519081016040528092919081815260200182805461294c90613822565b80156129995780601f1061296e57610100808354040283529160200191612999565b820191906000526020600020905b81548152906001019060200180831161297c57829003601f168201915b50505050509050808860000184815481106129b6576129b661367a565b9060005260206000200190816129cc91906139bc565b508388600101826040516129e09190613ad6565b90815260405190819003602001902055505b8654879080612a0357612a03613ae8565b600190038181906000526020600020016000612a1f9190612e3d565b9055866001018686604051612a359291906137b4565b9081526020016040518091039020600090556001935050505061085c565b600091505061085c565b6000612a6a848484612b7f565b612abb57835460018101855560008581526020902001612a8b838583613b17565b5083546040516001860190612aa390869086906137b4565b9081526040519081900360200190205550600161085c565b50600061085c565b6000806000612ad28585612baf565b90925090506000816004811115612aeb57612aeb612fd2565b148015612b2357508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b80612b345750612b34868686612bf4565b9695505050505050565b600060ff8216601f81111561087a576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000836001018383604051612b959291906137b4565b908152604051908190036020019020541515949350505050565b6000808251604103612be55760208301516040840151606085015160001a612bd987828585612d51565b94509450505050612bed565b506000905060025b9250929050565b60008060008573ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b8686604051602401612c2b929190613c32565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051612cb49190613ad6565b600060405180830381855afa9150503d8060008114612cef576040519150601f19603f3d011682016040523d82523d6000602084013e612cf4565b606091505b5091509150818015612d0857506020815110155b8015612b34575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090612d469083016020908101908401613875565b149695505050505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612d88575060009050600361188f565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612ddc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116612e305760006001925092505061188f565b9660009650945050505050565b508054612e4990613822565b6000825580601f10612e59575050565b601f0160209004906000526020600020908101906111d891905b80821115612e875760008155600101612e73565b5090565b73ffffffffffffffffffffffffffffffffffffffff811681146111d857600080fd5b600060208284031215612ebf57600080fd5b813561085c81612e8b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060408385031215612f0c57600080fd5b82359150602083013567ffffffffffffffff80821115612f2b57600080fd5b818501915085601f830112612f3f57600080fd5b813581811115612f5157612f51612eca565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715612f9757612f97612eca565b81604052828152886020848701011115612fb057600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60038110613038577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9052565b6040810161304a8285613001565b63ffffffff831660208301529392505050565b803560038110611cbb57600080fd5b60008060006060848603121561308157600080fd5b833592506130916020850161305d565b9150604084013590509250925092565b60005b838110156130bc5781810151838201526020016130a4565b50506000910152565b600081518084526130dd8160208601602086016130a1565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061087760208301846130c5565b6000806040838503121561313557600080fd5b823591506131456020840161305d565b90509250929050565b600081518084526020808501808196508360051b8101915082860160005b858110156131965782840389526131848483516130c5565b9885019893509084019060010161316c565b5091979650505050505050565b602081526000610877602083018461314e565b803563ffffffff81168114611cbb57600080fd5b60008083601f8401126131dc57600080fd5b50813567ffffffffffffffff8111156131f457600080fd5b602083019150836020828501011115612bed57600080fd5b803560ff81168114611cbb57600080fd5b600080600080600080600060a0888a03121561323857600080fd5b873561324381612e8b565b9650613251602089016131b6565b9550604088013567ffffffffffffffff8082111561326e57600080fd5b61327a8b838c016131ca565b909750955085915061328e60608b0161320c565b945060808a01359150808211156132a457600080fd5b506132b18a828b016131ca565b989b979a50959850939692959293505050565b6000806000606084860312156132d957600080fd5b6132e2846131b6565b92506132f06020850161320c565b9150604084013561330081612e8b565b809150509250925092565b60008083601f84011261331d57600080fd5b50813567ffffffffffffffff81111561333557600080fd5b6020830191508360208260051b8501011115612bed57600080fd5b6000806020838503121561336357600080fd5b823567ffffffffffffffff81111561337a57600080fd5b6133868582860161330b565b90969095509350505050565b6000602082840312156133a457600080fd5b5035919050565b600080602083850312156133be57600080fd5b823567ffffffffffffffff8111156133d557600080fd5b613386858286016131ca565b600080600080600080608087890312156133fa57600080fd5b863561340581612e8b565b9550602087013567ffffffffffffffff8082111561342257600080fd5b61342e8a838b016131ca565b909750955060408901359450606089013591508082111561344e57600080fd5b5061345b89828a016131ca565b979a9699509497509295939492505050565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e0818401526134a960e084018a6130c5565b83810360408501526134bb818a6130c5565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b8181101561351a578351835292840192918401916001016134fe565b50909c9b505050505050505050505050565b60008060006040848603121561354157600080fd5b83359250602084013567ffffffffffffffff81111561355f57600080fd5b61356b868287016131ca565b9497909650939450505050565b600060408201905061358b828451613001565b60209283015163ffffffff16919092015290565b600080604083850312156135b257600080fd5b6135bb836131b6565b91506131456020840161320c565b600080600080608085870312156135df57600080fd5b843593506135ef6020860161305d565b93969395505050506040820135916060013590565b604081526000613617604083018561314e565b90508260208301529392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b64ffffffffff81811683821601908082111561367357613673613626565b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18336030181126136dd57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261371c57600080fd5b83018035915067ffffffffffffffff82111561373757600080fd5b6020019150600581901b3603821315612bed57600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261378457600080fd5b83018035915067ffffffffffffffff82111561379f57600080fd5b602001915036819003821315612bed57600080fd5b8183823760009101908152919050565b8181038181111561087a5761087a613626565b8082018082111561087a5761087a613626565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361381b5761381b613626565b5060010190565b600181811c9082168061383657607f821691505b60208210810361386f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60006020828403121561388757600080fd5b5051919050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60208152600061085960208301848661388e565b6060815260006138ff60608301878961388e565b60ff86166020840152828103604084015261391b81858761388e565b98975050505050505050565b85815260606020820152600061394160608301868861388e565b828103604084015261391b81858761388e565b60006020828403121561396657600080fd5b8151801515811461085c57600080fd5b601f821115610d2c57600081815260208120601f850160051c8101602086101561399d5750805b601f850160051c820191505b8181101561110f578281556001016139a9565b815167ffffffffffffffff8111156139d6576139d6612eca565b6139ea816139e48454613822565b84613976565b602080601f831160018114613a3d5760008415613a075750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855561110f565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015613a8a57888601518255948401946001909101908401613a6b565b5085821015613ac657878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600082516136dd8184602087016130a1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b67ffffffffffffffff831115613b2f57613b2f612eca565b613b4383613b3d8354613822565b83613976565b6000601f841160018114613b955760008515613b5f5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355613c2b565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b82811015613be45786850135825560209485019460019092019101613bc4565b5086821015613c1f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b82815260406020820152600061085960408301846130c556fea164736f6c6343000815000a00000000000000000000000000000000fc6c5f01fc30151999387bb99a9f489b0000000000000000000000002d93c2f74b2c4697f9ea85d0450148aa45d4d5a2000000000000000000000000299707e127cc77de01b9fd968bc0ff475f3c634200000000000000000000000000000000000000000000000000000000000003e8

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102ff5760003560e01c80637cd07e471161019c578063a526d83b116100ee578063d881039511610097578063f27995e311610071578063f27995e3146107d3578063f2fde38b146107f4578063ffa1ad741461080757600080fd5b8063d88103951461076b578063e30c3978146107ac578063e33acf38146107ca57600080fd5b8063b221dac4116100c8578063b221dac41461071e578063b577556114610731578063d4c048091461075857600080fd5b8063a526d83b146106c2578063ac34cc5a146106d5578063b06faf62146106f557600080fd5b806384b0196e116101505780638fd3ab801161012a5780638fd3ab801461065a57806395e7549f14610662578063a06db7dc1461068757600080fd5b806384b0196e146105e25780638b21e484146105fd5780638da5cb5b1461063c57600080fd5b8063803347371161018157806380334737146105a757806381749468146105c75780638456cb59146105da57600080fd5b80637cd07e47146105515780637ecebe001461057157600080fd5b80634980f28811610255578063708e9c7011610209578063787bd966116101e3578063787bd9661461052e57806378e890ba1461054157806379ba50971461054957600080fd5b8063708e9c70146105005780637140415614610513578063715018a61461052657600080fd5b80635c975abb1161023a5780635c975abb146104ad5780636840b75e146104d057806369615a4c146104e357600080fd5b80634980f2881461047957806358edef4c1461049a57600080fd5b8063207e3d69116102b75780633f4ba83a116102915780633f4ba83a1461045657806346b3f4291461045e57806347cf8d4d1461047157600080fd5b8063207e3d691461041b57806323cf311814610430578063368ab6101461044357600080fd5b80630e24e34c116102e85780630e24e34c146103815780630ea9442c146103db5780631f64222f146103fb57600080fd5b80630633b14a146103045780630aa13b8c1461033c575b600080fd5b610327610312366004612ead565b60026020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b60075461035c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610333565b6103cd61038f366004612ef9565b600c602090815260009283526040909220815180830184018051928152908401929093019190912091525460ff811690610100900463ffffffff1682565b60405161033392919061303c565b6103ee6103e936600461306c565b610843565b604051610333919061310f565b61040e610409366004613122565b610863565b60405161033391906131a3565b61042e61042936600461321d565b610880565b005b61042e61043e366004612ead565b6108f9565b61042e6104513660046132c4565b6109fd565b61042e610b6d565b61042e61046c366004613350565b610b7f565b61042e610d31565b61048c610487366004613392565b610e1c565b604051908152602001610333565b61042e6104a83660046133ab565b610e27565b60015474010000000000000000000000000000000000000000900460ff16610327565b61048c6104de366004613122565b610e46565b33600090815260066020526040902080546001810190915561048c565b61042e61050e366004613350565b610e5e565b61042e610521366004612ead565b611058565b61042e6110d4565b61042e61053c3660046133e1565b6110e6565b61048c611117565b61042e611121565b60035461035c9073ffffffffffffffffffffffffffffffffffffffff1681565b61048c61057f366004612ead565b73ffffffffffffffffffffffffffffffffffffffff1660009081526006602052604090205490565b60085461035c9073ffffffffffffffffffffffffffffffffffffffff1681565b61042e6105d5366004612ead565b6111db565b61042e61127e565b6105ea6112f5565b604051610333979695949392919061346d565b6003546106269074010000000000000000000000000000000000000000900464ffffffffff1681565b60405164ffffffffff9091168152602001610333565b60005473ffffffffffffffffffffffffffffffffffffffff1661035c565b61042e61139a565b6008546103279074010000000000000000000000000000000000000000900460ff1681565b6106ae7f000000000000000000000000000000000000000000000000000000000001518081565b60405162ffffff9091168152602001610333565b61042e6106d0366004612ead565b6114cb565b6106e86106e336600461352c565b61154a565b6040516103339190613578565b60035474010000000000000000000000000000000000000000900464ffffffffff161515610327565b61042e61072c366004612ead565b6115d9565b61048c7f32e091a0c6fc95c826855f4e40ebda4957b528bd84c9062416ceb903082dabe481565b61042e610766366004613392565b6116d1565b61035c61077936600461359f565b600d60209081526000928352604080842090915290825290205473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1661035c565b61048c60095481565b6107e66107e13660046135c9565b611755565b604051610333929190613604565b61042e610802366004612ead565b611898565b6103ee6040518060400160405280600a81526020017f323032332e31312e31350000000000000000000000000000000000000000000081525081565b6060610859826108538686611948565b906119d6565b90505b9392505050565b60606108776108728484611948565b611a88565b90505b92915050565b610888611b65565b60085473ffffffffffffffffffffffffffffffffffffffff1633146108d9576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108f06108e588611bea565b878787878787611cc0565b50505050505050565b610901611cd1565b60035474010000000000000000000000000000000000000000900464ffffffffff161561095a576040517fca1c3cbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610962611d52565b6003546040805173ffffffffffffffffffffffffffffffffffffffff928316815291831660208301527fd8ad954fe808212ab9ed7139873e40807dff7995fe36e3d6cdeb8fa00fcebf10910160405180910390a1600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b610a05611cd1565b8263ffffffff16600003610a45576040517f36dccb4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8160ff16600003610a82576040517f5110099800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff83166000818152600d6020908152604080832060ff8716808552908352928190205481519485529184019290925273ffffffffffffffffffffffffffffffffffffffff9081168383015283166060830152517fd964242236f6208120d76a25cd886db49c82403f50d88dfd1bc865ee60ad462d9181900360800190a163ffffffff9092166000908152600d6020908152604080832060ff909416835292905220805473ffffffffffffffffffffffffffffffffffffffff9092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909216919091179055565b610b75611cd1565b610b7d611dd6565b565b60035473ffffffffffffffffffffffffffffffffffffffff163314610bd0576040517f8020644900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035474010000000000000000000000000000000000000000900464ffffffffff1615158015610c575750600354610c4d907f000000000000000000000000000000000000000000000000000000000001518062ffffff169074010000000000000000000000000000000000000000900464ffffffffff16613655565b64ffffffffff1642115b15610c8e576040517fca0dc97b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c96611d52565b60005b81811015610d2c5736838383818110610cb457610cb461367a565b9050602002810190610cc691906136a9565b905060005b610cd860208301836136e7565b9050811015610d2257610d1a8235610cf360208501856136e7565b84818110610d0357610d0361367a565b9050602002810190610d15919061374f565b611e53565b600101610ccb565b5050600101610c99565b505050565b610d39611cd1565b60085474010000000000000000000000000000000000000000900460ff1615610d8e576040517f351f92c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60085460405173ffffffffffffffffffffffffffffffffffffffff90911681527fcb685c7ba5a65fe9e6be9b7decbb5dc8ebba92bcae3cb09fc2a5a075b1eb57729060200160405180910390a1600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b600061087a82611f5a565b610e2f611b65565b610e42610e3b33611bea565b8383611fa2565b5050565b6000610877610e558484611948565b5490565b905090565b60035473ffffffffffffffffffffffffffffffffffffffff163314610eaf576040517f8020644900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035474010000000000000000000000000000000000000000900464ffffffffff1615158015610f365750600354610f2c907f000000000000000000000000000000000000000000000000000000000001518062ffffff169074010000000000000000000000000000000000000000900464ffffffffff16613655565b64ffffffffff1642115b15610f6d576040517fca0dc97b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610f75611d52565b60005b81811015610d2c5736838383818110610f9357610f9361367a565b9050602002810190610fa591906136a9565b905060005b610fb760208301836136e7565b905081101561104e5761104682356001610fd460208601866136e7565b85818110610fe457610fe461367a565b9050602002810190610ff691906136a9565b611000908061374f565b600161100f60208901896136e7565b8881811061101f5761101f61367a565b905060200281019061103191906136a9565b61103f90602081019061374f565b600061209e565b600101610faa565b5050600101610f78565b611060611cd1565b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055517fbe7c7ac3248df4581c206a84aab3cb4e7d521b5398b42b681757f78a5a7d411e9190a250565b6110dc611cd1565b610b7d6000612371565b6110ee611b65565b6110fc8686868686866123a2565b61110f61110887611bea565b8686611fa2565b505050505050565b6000610e596124ae565b600154339073ffffffffffffffffffffffffffffffffffffffff1681146111cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e6572000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6111d881612371565b50565b6111e3611cd1565b6007546040805173ffffffffffffffffffffffffffffffffffffffff928316815291831660208301527f940dcf34ec2e245e837ee4599997e577ce274d7b87c73238e2878ac7ea1af2f1910160405180910390a1600780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633148015906112b657503360009081526002602052604090205460ff16155b156112ed576040517fcae1d95600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b7d6125e6565b6000606080828080836113297f466172636173746572204b6579526567697374727900000000000000000000156004612655565b6113547f31000000000000000000000000000000000000000000000000000000000000016005612655565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b60035473ffffffffffffffffffffffffffffffffffffffff1633146113eb576040517f8020644900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035474010000000000000000000000000000000000000000900464ffffffffff1615611444576040517fca1c3cbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61144c611d52565b600380547fffffffffffffff0000000000ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000004264ffffffffff90811682029290921792839055604051920416907fe4a25c0c2cbe89d6ad8b64c61a7dbdd20d1f781f6023f1ab94ebb7fe0aef6ab890600090a2565b6114d3611cd1565b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055517f87dc5eecd6d6bdeae407c426da6bfba5b7190befc554ed5d4d62dd5cf939fbae9190a250565b60408051808201909152600080825260208201526000848152600c602052604090819020905161157d90859085906137b4565b908152604080519182900360200182208282019091528054829060ff1660028111156115ab576115ab612fd2565b60028111156115bc576115bc612fd2565b81529054610100900463ffffffff16602090910152949350505050565b6115e1611cd1565b60085474010000000000000000000000000000000000000000900460ff1615611636576040517f351f92c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6008546040805173ffffffffffffffffffffffffffffffffffffffff928316815291831660208301527f56785750704201befc0a27dae1e5d37835a8ad6e35affc87136ed24d1ac694ac910160405180910390a1600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6116d9611cd1565b6009548111611714576040517fc5ce0d9800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60095460408051918252602082018390527f6c336d0e5e74bb26a5e2d4646801801837b0fdbaddd9131923fd42d740449731910160405180910390a1600955565b60606000806117648787611948565b90506000611770825490565b90508086106117b25760408051600080825260208201909252906117a4565b606081526020019060019003908161178f5790505b50600093509350505061188f565b60006117be87836137c4565b905060008682106117cf57866117d1565b815b90508067ffffffffffffffff8111156117ec576117ec612eca565b60405190808252806020026020018201604052801561181f57816020015b606081526020019060019003908161180a5790505b50955060005b818110156118715761184161183a828b6137d7565b86906119d6565b8782815181106118535761185361367a565b60200260200101819052508080611869906137ea565b915050611825565b5061187c81896137d7565b945082851061188a57600094505b505050505b94509492505050565b6118a0611cd1565b6001805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915561190360005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000600182600281111561195e5761195e612fd2565b0361197757506000828152600a6020526040902061087a565b600282600281111561198b5761198b612fd2565b036119a457506000828152600b6020526040902061087a565b6040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60608260000182815481106119ed576119ed61367a565b906000526020600020018054611a0290613822565b80601f0160208091040260200160405190810160405280929190818152602001828054611a2e90613822565b8015611a7b5780601f10611a5057610100808354040283529160200191611a7b565b820191906000526020600020905b815481529060010190602001808311611a5e57829003601f168201915b5050505050905092915050565b606081600001805480602002602001604051908101604052809291908181526020016000905b82821015611b5a578382906000526020600020018054611acd90613822565b80601f0160208091040260200160405190810160405280929190818152602001828054611af990613822565b8015611b465780601f10611b1b57610100808354040283529160200191611b46565b820191906000526020600020905b815481529060010190602001808311611b2957829003601f168201915b505050505081526020019060010190611aae565b505050509050919050565b60015474010000000000000000000000000000000000000000900460ff1615610b7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016111c6565b6007546040517fd94fe83200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152600092169063d94fe83290602401602060405180830381865afa158015611c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7f9190613875565b905080600003611cbb576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6108f087878787878787600161209e565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016111c6565b60015474010000000000000000000000000000000000000000900460ff16610b7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016111c6565b611dde611d52565b600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b6000838152600c60205260408082209051611e7190859085906137b4565b90815260405190819003602001902090506001815460ff166002811115611e9a57611e9a612fd2565b14611ed1576040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611edc848484612700565b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000168155604051611f1290849084906137b4565b6040518091039020847f1ecc1009ebad5d2fb61239462f4f9f6f152662defe1845fc87f07d96bd1c60b48585604051611f4c9291906138d7565b60405180910390a350505050565b600061087a611f676124ae565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b6000838152600c60205260408082209051611fc090859085906137b4565b90815260405190819003602001902090506001815460ff166002811115611fe957611fe9612fd2565b14612020576040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61202b84848461271f565b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600217815560405161206490849084906137b4565b6040518091039020847f09e77066e0155f46785be12f6938a6b2e4be4381e59058129ce15f355cb969588585604051611f4c9291906138d7565b6000888152600c602052604080822090516120bc90899089906137b4565b90815260405190819003602001902090506000815460ff1660028111156120e5576120e5612fd2565b1461211c576040517fbaf3f0f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60095461212a8a6001610e46565b10612161576040517f2926404200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff88166000908152600d6020908152604080832060ff8916845290915290205473ffffffffffffffffffffffffffffffffffffffff16806121e3576040517fb736f27f00000000000000000000000000000000000000000000000000000000815263ffffffff8a16600482015260ff871660248201526044016111c6565b6121ee8a8989612752565b815463ffffffff8a16610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000090911617600117825560405161223590899089906137b4565b60405180910390208963ffffffff168b7f7d285df41058466977811345cd453c0c52e8d841ffaabc74fc050f277ad4de028b8b8b8b8b60405161227c9594939291906138eb565b60405180910390a48215612365576040517faa4e0ce800000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff83169063aa4e0ce8906122e7908e908d908d908c908c90600401613927565b6020604051808303816000875af1158015612306573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232a9190613954565b905080612363576040517fbcecb64a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b50505050505050505050565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556111d88161276b565b61110f6124707f32e091a0c6fc95c826855f4e40ebda4957b528bd84c9062416ceb903082dabe48888886040516123da9291906137b4565b60405180910390206124168b73ffffffffffffffffffffffffffffffffffffffff16600090815260066020526040902080546001810190915590565b60408051602081019590955273ffffffffffffffffffffffffffffffffffffffff909316928401929092526060830152608082015260a0810186905260c00160405160208183030381529060405280519060200120611f5a565b878585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506127e092505050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000fc1237824fb747abde0ff18990e59b7e1614801561251457507f000000000000000000000000000000000000000000000000000000000000000a46145b1561253e57507fff3ecb95b37f8812f0476e95e5aa93b8a55c60c43d2300e92854be3a1a380cf990565b610e59604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527faa768cc38131c77b49c9fbf00aa458bd9ab839a7ca2b242e444962d8177a84d4918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6125ee611b65565b600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e293390565b606060ff831461266f576126688361285b565b905061087a565b81805461267b90613822565b80601f01602080910402602001604051908101604052809291908181526020018280546126a790613822565b80156126f45780601f106126c9576101008083540402835291602001916126f4565b820191906000526020600020905b8154815290600101906020018083116126d757829003601f168201915b5050505050905061087a565b6000838152600a6020526040902061271990838361289a565b50505050565b6000838152600a6020526040902061273890838361289a565b506000838152600b60205260409020612719908383612a5d565b6000838152600a60205260409020612719908383612a5d565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8142111561281a576040517f0819bdcd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612825838583612ac3565b612719576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060600061286883612b3e565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b6000808460010184846040516128b19291906137b4565b908152602001604051809103902054905080600014612a535760006128d76001836137c4565b86549091506000906128eb906001906137c4565b90508181146129f257600087600001828154811061290b5761290b61367a565b90600052602060002001805461292090613822565b80601f016020809104026020016040519081016040528092919081815260200182805461294c90613822565b80156129995780601f1061296e57610100808354040283529160200191612999565b820191906000526020600020905b81548152906001019060200180831161297c57829003601f168201915b50505050509050808860000184815481106129b6576129b661367a565b9060005260206000200190816129cc91906139bc565b508388600101826040516129e09190613ad6565b90815260405190819003602001902055505b8654879080612a0357612a03613ae8565b600190038181906000526020600020016000612a1f9190612e3d565b9055866001018686604051612a359291906137b4565b9081526020016040518091039020600090556001935050505061085c565b600091505061085c565b6000612a6a848484612b7f565b612abb57835460018101855560008581526020902001612a8b838583613b17565b5083546040516001860190612aa390869086906137b4565b9081526040519081900360200190205550600161085c565b50600061085c565b6000806000612ad28585612baf565b90925090506000816004811115612aeb57612aeb612fd2565b148015612b2357508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b80612b345750612b34868686612bf4565b9695505050505050565b600060ff8216601f81111561087a576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000836001018383604051612b959291906137b4565b908152604051908190036020019020541515949350505050565b6000808251604103612be55760208301516040840151606085015160001a612bd987828585612d51565b94509450505050612bed565b506000905060025b9250929050565b60008060008573ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b8686604051602401612c2b929190613c32565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051612cb49190613ad6565b600060405180830381855afa9150503d8060008114612cef576040519150601f19603f3d011682016040523d82523d6000602084013e612cf4565b606091505b5091509150818015612d0857506020815110155b8015612b34575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090612d469083016020908101908401613875565b149695505050505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612d88575060009050600361188f565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612ddc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116612e305760006001925092505061188f565b9660009650945050505050565b508054612e4990613822565b6000825580601f10612e59575050565b601f0160209004906000526020600020908101906111d891905b80821115612e875760008155600101612e73565b5090565b73ffffffffffffffffffffffffffffffffffffffff811681146111d857600080fd5b600060208284031215612ebf57600080fd5b813561085c81612e8b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060408385031215612f0c57600080fd5b82359150602083013567ffffffffffffffff80821115612f2b57600080fd5b818501915085601f830112612f3f57600080fd5b813581811115612f5157612f51612eca565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715612f9757612f97612eca565b81604052828152886020848701011115612fb057600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60038110613038577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9052565b6040810161304a8285613001565b63ffffffff831660208301529392505050565b803560038110611cbb57600080fd5b60008060006060848603121561308157600080fd5b833592506130916020850161305d565b9150604084013590509250925092565b60005b838110156130bc5781810151838201526020016130a4565b50506000910152565b600081518084526130dd8160208601602086016130a1565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061087760208301846130c5565b6000806040838503121561313557600080fd5b823591506131456020840161305d565b90509250929050565b600081518084526020808501808196508360051b8101915082860160005b858110156131965782840389526131848483516130c5565b9885019893509084019060010161316c565b5091979650505050505050565b602081526000610877602083018461314e565b803563ffffffff81168114611cbb57600080fd5b60008083601f8401126131dc57600080fd5b50813567ffffffffffffffff8111156131f457600080fd5b602083019150836020828501011115612bed57600080fd5b803560ff81168114611cbb57600080fd5b600080600080600080600060a0888a03121561323857600080fd5b873561324381612e8b565b9650613251602089016131b6565b9550604088013567ffffffffffffffff8082111561326e57600080fd5b61327a8b838c016131ca565b909750955085915061328e60608b0161320c565b945060808a01359150808211156132a457600080fd5b506132b18a828b016131ca565b989b979a50959850939692959293505050565b6000806000606084860312156132d957600080fd5b6132e2846131b6565b92506132f06020850161320c565b9150604084013561330081612e8b565b809150509250925092565b60008083601f84011261331d57600080fd5b50813567ffffffffffffffff81111561333557600080fd5b6020830191508360208260051b8501011115612bed57600080fd5b6000806020838503121561336357600080fd5b823567ffffffffffffffff81111561337a57600080fd5b6133868582860161330b565b90969095509350505050565b6000602082840312156133a457600080fd5b5035919050565b600080602083850312156133be57600080fd5b823567ffffffffffffffff8111156133d557600080fd5b613386858286016131ca565b600080600080600080608087890312156133fa57600080fd5b863561340581612e8b565b9550602087013567ffffffffffffffff8082111561342257600080fd5b61342e8a838b016131ca565b909750955060408901359450606089013591508082111561344e57600080fd5b5061345b89828a016131ca565b979a9699509497509295939492505050565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e0818401526134a960e084018a6130c5565b83810360408501526134bb818a6130c5565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b8181101561351a578351835292840192918401916001016134fe565b50909c9b505050505050505050505050565b60008060006040848603121561354157600080fd5b83359250602084013567ffffffffffffffff81111561355f57600080fd5b61356b868287016131ca565b9497909650939450505050565b600060408201905061358b828451613001565b60209283015163ffffffff16919092015290565b600080604083850312156135b257600080fd5b6135bb836131b6565b91506131456020840161320c565b600080600080608085870312156135df57600080fd5b843593506135ef6020860161305d565b93969395505050506040820135916060013590565b604081526000613617604083018561314e565b90508260208301529392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b64ffffffffff81811683821601908082111561367357613673613626565b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18336030181126136dd57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261371c57600080fd5b83018035915067ffffffffffffffff82111561373757600080fd5b6020019150600581901b3603821315612bed57600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261378457600080fd5b83018035915067ffffffffffffffff82111561379f57600080fd5b602001915036819003821315612bed57600080fd5b8183823760009101908152919050565b8181038181111561087a5761087a613626565b8082018082111561087a5761087a613626565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361381b5761381b613626565b5060010190565b600181811c9082168061383657607f821691505b60208210810361386f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60006020828403121561388757600080fd5b5051919050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60208152600061085960208301848661388e565b6060815260006138ff60608301878961388e565b60ff86166020840152828103604084015261391b81858761388e565b98975050505050505050565b85815260606020820152600061394160608301868861388e565b828103604084015261391b81858761388e565b60006020828403121561396657600080fd5b8151801515811461085c57600080fd5b601f821115610d2c57600081815260208120601f850160051c8101602086101561399d5750805b601f850160051c820191505b8181101561110f578281556001016139a9565b815167ffffffffffffffff8111156139d6576139d6612eca565b6139ea816139e48454613822565b84613976565b602080601f831160018114613a3d5760008415613a075750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855561110f565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015613a8a57888601518255948401946001909101908401613a6b565b5085821015613ac657878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600082516136dd8184602087016130a1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b67ffffffffffffffff831115613b2f57613b2f612eca565b613b4383613b3d8354613822565b83613976565b6000601f841160018114613b955760008515613b5f5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355613c2b565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b82811015613be45786850135825560209485019460019092019101613bc4565b5086821015613c1f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b82815260406020820152600061085960408301846130c556fea164736f6c6343000815000a

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000000000000fc6c5f01fc30151999387bb99a9f489b0000000000000000000000002d93c2f74b2c4697f9ea85d0450148aa45d4d5a2000000000000000000000000299707e127cc77de01b9fd968bc0ff475f3c634200000000000000000000000000000000000000000000000000000000000003e8

-----Decoded View---------------
Arg [0] : _idRegistry (address): 0x00000000Fc6c5F01Fc30151999387Bb99A9f489b
Arg [1] : _migrator (address): 0x2D93c2F74b2C4697f9ea85D0450148AA45D4D5a2
Arg [2] : _initialOwner (address): 0x299707E127CC77DE01b9Fd968Bc0ff475f3C6342
Arg [3] : _maxKeysPerFid (uint256): 1000

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000fc6c5f01fc30151999387bb99a9f489b
Arg [1] : 0000000000000000000000002d93c2f74b2c4697f9ea85d0450148aa45d4d5a2
Arg [2] : 000000000000000000000000299707e127cc77de01b9fd968bc0ff475f3c6342
Arg [3] : 00000000000000000000000000000000000000000000000000000000000003e8


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.