Contract 0x9b6f5ef589A3DD08670Dd146C11C4Fb33E04494F 12

 
Txn Hash Method
Block
From
To
Value
0x48f053374327c8805d15fb7286b715c314d45cb3a63e5f59af52b2bebaa07b540x60806040116787972024-03-11 8:49:0138 days 17 hrs ago0xeaf6183bab3efd3bf856ac5c058431c8592394d6 IN  Create: CrossChainControllerUpgradeRev20 ETH0.0105641759260.001000283
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
CrossChainControllerUpgradeRev2

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion, GNU GPLv3 license
File 1 of 26 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private 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 value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private 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, as noted in {at}.

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

            if (lastIndex != toDeleteIndex) {
                bytes32 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(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private 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(Set storage set, uint256 index) private view returns (bytes32) {
        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(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

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

    /**
     * @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(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, 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(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

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

    /**
     * @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(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, 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(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

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

    /**
     * @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(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, 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(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 2 of 26 : OwnableWithGuardian.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0;

import {IWithGuardian} from './interfaces/IWithGuardian.sol';
import {Ownable} from '../oz-common/Ownable.sol';

abstract contract OwnableWithGuardian is Ownable, IWithGuardian {
  address private _guardian;

  constructor() {
    _updateGuardian(_msgSender());
  }

  modifier onlyGuardian() {
    _checkGuardian();
    _;
  }

  modifier onlyOwnerOrGuardian() {
    _checkOwnerOrGuardian();
    _;
  }

  function guardian() public view override returns (address) {
    return _guardian;
  }

  /// @inheritdoc IWithGuardian
  function updateGuardian(address newGuardian) external override onlyOwnerOrGuardian {
    _updateGuardian(newGuardian);
  }

  /**
   * @dev method to update the guardian
   * @param newGuardian the new guardian address
   */
  function _updateGuardian(address newGuardian) internal {
    address oldGuardian = _guardian;
    _guardian = newGuardian;
    emit GuardianUpdated(oldGuardian, newGuardian);
  }

  function _checkGuardian() internal view {
    require(guardian() == _msgSender(), 'ONLY_BY_GUARDIAN');
  }

  function _checkOwnerOrGuardian() internal view {
    require(_msgSender() == owner() || _msgSender() == guardian(), 'ONLY_BY_OWNER_OR_GUARDIAN');
  }
}

File 3 of 26 : IWithGuardian.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0;

interface IWithGuardian {
  /**
   * @dev Event emitted when guardian gets updated
   * @param oldGuardian address of previous guardian
   * @param newGuardian address of the new guardian
   */
  event GuardianUpdated(address oldGuardian, address newGuardian);

  /**
   * @dev get guardian address;
   */
  function guardian() external view returns (address);

  /**
   * @dev method to update the guardian
   * @param newGuardian the new guardian address
   */
  function updateGuardian(address newGuardian) external;
}

File 4 of 26 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
// From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/8b778fa20d6d76340c5fac1ed66c80273f05b95a

pragma solidity ^0.8.1;

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

    return account.code.length > 0;
  }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 5 of 26 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
// From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/8b778fa20d6d76340c5fac1ed66c80273f05b95a

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 6 of 26 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
// From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/8b778fa20d6d76340c5fac1ed66c80273f05b95a

pragma solidity ^0.8.0;

import './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 anymore. Can only be called by the current owner.
   *
   * NOTE: Renouncing ownership will leave the contract without an owner,
   * thereby removing any functionality that is only available to the owner.
   */
  function renounceOwnership() public virtual onlyOwner {
    _transferOwnership(address(0));
  }

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

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

File 7 of 26 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
// Modified From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/00cbf5a236564c3b7aacdad1f378cae22d890ca6

pragma solidity ^0.8.0;

import {IERC20} from "./interfaces/IERC20.sol";
import {IERC20Permit} from "./interfaces/IERC20Permit.sol";
import {Address} from "./Address.sol";

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

  /**
   * @dev An operation with an ERC20 token failed.
     */
  error SafeERC20FailedOperation(address token);

  /**
   * @dev Indicates a failed `decreaseAllowance` request.
     */
  error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

  /**
   * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
  function safeTransfer(IERC20 token, address to, uint256 value) internal {
    _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
  }

  /**
   * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
  function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
    _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
  }

  /**
   * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
  function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
    uint256 oldAllowance = token.allowance(address(this), spender);
    forceApprove(token, spender, oldAllowance + value);
  }

  /**
   * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
  function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
    unchecked {
      uint256 currentAllowance = token.allowance(address(this), spender);
      if (currentAllowance < requestedDecrease) {
        revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
      }
      forceApprove(token, spender, currentAllowance - requestedDecrease);
    }
  }

  /**
   * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
  function forceApprove(IERC20 token, address spender, uint256 value) internal {
    bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

    if (!_callOptionalReturnBool(token, approvalCall)) {
      _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
      _callOptionalReturn(token, approvalCall);
    }
  }

  /**
   * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
  function safePermit(
    IERC20Permit token,
    address owner,
    address spender,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) internal {
    uint256 nonceBefore = token.nonces(owner);
    token.permit(owner, spender, value, deadline, v, r, s);
    uint256 nonceAfter = token.nonces(owner);
    if (nonceAfter != nonceBefore + 1) {
      revert SafeERC20FailedOperation(address(token));
    }
  }

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

    bytes memory returndata = address(token).functionCall(data);
    if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
      revert SafeERC20FailedOperation(address(token));
    }
  }

  /**
   * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
  function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
    // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
    // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
    // and not revert is the subcall reverts.

    (bool success, bytes memory returndata) = address(token).call(data);
    return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
  }
}

File 8 of 26 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
// From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/a035b235b4f2c9af4ba88edc4447f02e37f8d124

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 9 of 26 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
// Modified from https://github.com/OpenZeppelin/openzeppelin-contracts/commit/00cbf5a236564c3b7aacdad1f378cae22d890ca6
pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
  /**
   * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
  function permit(
    address owner,
    address spender,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external;

  /**
   * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
  function nonces(address owner) external view returns (uint256);

  /**
   * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
  // solhint-disable-next-line func-name-mixedcase
  function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 10 of 26 : Initializable.sol
// SPDX-License-Identifier: MIT

/**
 * @dev OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
 * From https://github.com/OpenZeppelin/openzeppelin-contracts/tree/8b778fa20d6d76340c5fac1ed66c80273f05b95a
 *
 * BGD Labs adaptations:
 * - Added a constructor disabling initialization for implementation contracts
 * - Linting
 */

pragma solidity ^0.8.2;

import '../oz-common/Address.sol';

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

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

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

  /**
   * @dev OPINIONATED. Generally is not a good practise to allow initialization of implementations
   */
  constructor() {
    _disableInitializers();
  }

  /**
   * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
   * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
   */
  modifier initializer() {
    bool isTopLevelCall = !_initializing;
    require(
      (isTopLevelCall && _initialized < 1) ||
        (!Address.isContract(address(this)) && _initialized == 1),
      'Initializable: contract is already initialized'
    );
    _initialized = 1;
    if (isTopLevelCall) {
      _initializing = true;
    }
    _;
    if (isTopLevelCall) {
      _initializing = false;
      emit Initialized(1);
    }
  }

  /**
   * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
   * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
   * used to initialize parent contracts.
   *
   * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
   * initialization step. This is essential to configure modules that are added through upgrades and that require
   * initialization.
   *
   * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
   * a contract, executing them in the right order is up to the developer or operator.
   */
  modifier reinitializer(uint8 version) {
    require(
      !_initializing && _initialized < version,
      'Initializable: contract is already initialized'
    );
    _initialized = version;
    _initializing = true;
    _;
    _initializing = false;
    emit Initialized(version);
  }

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

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

File 11 of 26 : Rescuable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

import {IERC20} from '../oz-common/interfaces/IERC20.sol';
import {SafeERC20} from '../oz-common/SafeERC20.sol';
import {IRescuable} from './interfaces/IRescuable.sol';

/**
 * @title Rescuable
 * @author BGD Labs
 * @notice abstract contract with the methods to rescue tokens (ERC20 and native)  from a contract
 */
abstract contract Rescuable is IRescuable {
  using SafeERC20 for IERC20;

  /// @notice modifier that checks that caller is allowed address
  modifier onlyRescueGuardian() {
    require(msg.sender == whoCanRescue(), 'ONLY_RESCUE_GUARDIAN');
    _;
  }

  /// @inheritdoc IRescuable
  function emergencyTokenTransfer(
    address erc20Token,
    address to,
    uint256 amount
  ) external onlyRescueGuardian {
    IERC20(erc20Token).safeTransfer(to, amount);

    emit ERC20Rescued(msg.sender, erc20Token, to, amount);
  }

  /// @inheritdoc IRescuable
  function emergencyEtherTransfer(address to, uint256 amount) external onlyRescueGuardian {
    (bool success, ) = to.call{value: amount}(new bytes(0));
    require(success, 'ETH_TRANSFER_FAIL');

    emit NativeTokensRescued(msg.sender, to, amount);
  }

  /// @inheritdoc IRescuable
  function whoCanRescue() public view virtual returns (address);
}

File 12 of 26 : IRescuable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

/**
 * @title IRescuable
 * @author BGD Labs
 * @notice interface containing the objects, events and methods definitions of the Rescuable contract
 */
interface IRescuable {
  /**
   * @notice emitted when erc20 tokens get rescued
   * @param caller address that triggers the rescue
   * @param token address of the rescued token
   * @param to address that will receive the rescued tokens
   * @param amount quantity of tokens rescued
   */
  event ERC20Rescued(
    address indexed caller,
    address indexed token,
    address indexed to,
    uint256 amount
  );

  /**
   * @notice emitted when native tokens get rescued
   * @param caller address that triggers the rescue
   * @param to address that will receive the rescued tokens
   * @param amount quantity of tokens rescued
   */
  event NativeTokensRescued(address indexed caller, address indexed to, uint256 amount);

  /**
   * @notice method called to rescue tokens sent erroneously to the contract. Only callable by owner
   * @param erc20Token address of the token to rescue
   * @param to address to send the tokens
   * @param amount of tokens to rescue
   */
  function emergencyTokenTransfer(address erc20Token, address to, uint256 amount) external;

  /**
   * @notice method called to rescue ether sent erroneously to the contract. Only callable by owner
   * @param to address to send the eth
   * @param amount of eth to rescue
   */
  function emergencyEtherTransfer(address to, uint256 amount) external;

  /**
   * @notice method that defines the address that is allowed to rescue tokens
   * @return the allowed address
   */
  function whoCanRescue() external view returns (address);
}

File 13 of 26 : BaseCrossChainController.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.8;

import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol';
import {Rescuable} from 'solidity-utils/contracts/utils/Rescuable.sol';
import {IRescuable} from 'solidity-utils/contracts/utils/interfaces/IRescuable.sol';
import {CrossChainReceiver} from './CrossChainReceiver.sol';
import {CrossChainForwarder} from './CrossChainForwarder.sol';
import {Errors} from './libs/Errors.sol';

import {IBaseCrossChainController} from './interfaces/IBaseCrossChainController.sol';

/**
 * @title BaseCrossChainController
 * @author BGD Labs
 * @notice Contract with the logic to manage sending and receiving messages cross chain.
 * @dev This contract is enabled to receive gas tokens as its the one responsible for bridge services payment.
        It should always be topped up, or no messages will be sent to other chains
 */
contract BaseCrossChainController is
  IBaseCrossChainController,
  Rescuable,
  CrossChainForwarder,
  CrossChainReceiver,
  Initializable
{
  constructor()
    CrossChainReceiver(new ConfirmationInput[](0), new ReceiverBridgeAdapterConfigInput[](0))
    CrossChainForwarder(new ForwarderBridgeAdapterConfigInput[](0), new address[](0))
  {}

  /// @dev child class should make a call of this method
  function _baseInitialize(
    address owner,
    address guardian,
    ConfirmationInput[] memory initialRequiredConfirmations,
    ReceiverBridgeAdapterConfigInput[] memory receiverBridgeAdaptersToAllow,
    ForwarderBridgeAdapterConfigInput[] memory forwarderBridgeAdaptersToEnable,
    address[] memory sendersToApprove
  ) internal initializer {
    _transferOwnership(owner);
    _updateGuardian(guardian);

    _configureReceiverBasics(
      receiverBridgeAdaptersToAllow,
      new ReceiverBridgeAdapterConfigInput[](0), // On first init, no bridges to disable
      initialRequiredConfirmations
    );

    _configureForwarderBasics(
      forwarderBridgeAdaptersToEnable,
      new BridgeAdapterToDisable[](0), // On first init, no bridges to disable
      sendersToApprove,
      new address[](0) // On first init, no senders to unauthorize
    );
  }

  /// @inheritdoc IRescuable
  function whoCanRescue() public view override(IRescuable, Rescuable) returns (address) {
    return owner();
  }

  /// @notice Enable contract to receive ETH/Native token
  receive() external payable {}
}

File 14 of 26 : CrossChainController.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.8;

import {ICrossChainController} from './interfaces/ICrossChainController.sol';
import {BaseCrossChainController} from './BaseCrossChainController.sol';

/**
 * @title CrossChainController
 * @author BGD Labs
 * @notice CrossChainController contract adopted for usage on the chain where Governance deployed (mainnet in our case)
 */
contract CrossChainController is ICrossChainController, BaseCrossChainController {
  /// @inheritdoc ICrossChainController
  function initialize(
    address owner,
    address guardian,
    ConfirmationInput[] memory initialRequiredConfirmations,
    ReceiverBridgeAdapterConfigInput[] memory receiverBridgeAdaptersToAllow,
    ForwarderBridgeAdapterConfigInput[] memory forwarderBridgeAdaptersToEnable,
    address[] memory sendersToApprove
  ) external initializer {
    _baseInitialize(
      owner,
      guardian,
      initialRequiredConfirmations,
      receiverBridgeAdaptersToAllow,
      forwarderBridgeAdaptersToEnable,
      sendersToApprove
    );
  }
}

File 15 of 26 : CrossChainForwarder.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.8;

import {OwnableWithGuardian} from 'solidity-utils/contracts/access-control/OwnableWithGuardian.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';

import {ICrossChainForwarder} from './interfaces/ICrossChainForwarder.sol';
import {IBaseAdapter} from './adapters/IBaseAdapter.sol';
import {Transaction, EncodedTransaction, Envelope, EncodedEnvelope, TransactionUtils} from './libs/EncodingUtils.sol';
import {Errors} from './libs/Errors.sol';

/**
 * @title CrossChainForwarder
 * @author BGD Labs
 * @notice this contract contains the methods used to forward messages to different chains
 *         using registered bridge adapters.
 * @dev To be able to forward a message, caller needs to be an approved sender.
 */
contract CrossChainForwarder is OwnableWithGuardian, ICrossChainForwarder {
  // every message originator sends we put into an envelope and attach a nonce. It increments by one
  uint256 internal _currentEnvelopeNonce;

  // for every new bridging attempt of an envelope we attach a txId, that will be unique for every attempt. It increments by one
  // the rationality behind - is to be able to deliver envelope anyways, even if destination chain infra will be invalidated
  // so, we will be able to retry the envelope with the same nonce once it will recover
  uint256 internal _currentTransactionNonce;

  // specifies if an address is approved to forward messages
  mapping(address => bool) internal _approvedSenders;

  // Stores messages accepted from origin. hash(destinationChainId + (envelopeNonce, origin, destination, message)).
  // This is used to check if an envelop can be retried, in case one or more of bridges was out of gas at the forwardMessage call
  mapping(bytes32 => bool) internal _registeredEnvelopes;

  // Stores transactions sent. hash(transactionNonce, envelopeId).
  // This is used to check if a transaction can be retried
  // in a case when during the confirmation by recipient the recipient infrastructure got invalidated
  mapping(bytes32 => bool) internal _forwardedTransactions;

  // (chainId => chain configuration) list of bridge adapter configurations for a chain
  mapping(uint256 => ChainIdBridgeConfig[]) internal _bridgeAdaptersByChain;

  // storage gap allocation to be used for later updates. This way storage can be added on parent contract without
  // overwriting storage on child
  uint256[50] private __FORWARDER_GAP;

  // checks if caller is an approved sender
  modifier onlyApprovedSenders() {
    require(isSenderApproved(msg.sender), Errors.CALLER_IS_NOT_APPROVED_SENDER);
    _;
  }

  /**
   * @param bridgeAdaptersToEnable list of bridge adapter configurations to enable
   * @param sendersToApprove list of addresses to approve to forward messages
   */
  constructor(
    ForwarderBridgeAdapterConfigInput[] memory bridgeAdaptersToEnable,
    address[] memory sendersToApprove
  ) {
    _configureForwarderBasics(
      bridgeAdaptersToEnable,
      new BridgeAdapterToDisable[](0),
      sendersToApprove,
      new address[](0)
    );
  }

  /// @inheritdoc ICrossChainForwarder
  function getCurrentEnvelopeNonce() external view returns (uint256) {
    return _currentEnvelopeNonce;
  }

  /// @inheritdoc ICrossChainForwarder
  function getCurrentTransactionNonce() external view returns (uint256) {
    return _currentTransactionNonce;
  }

  /// @inheritdoc ICrossChainForwarder
  function isSenderApproved(address sender) public view returns (bool) {
    return _approvedSenders[sender];
  }

  /// @inheritdoc ICrossChainForwarder
  function isEnvelopeRegistered(Envelope memory envelope) public view returns (bool) {
    return isEnvelopeRegistered(envelope.getId());
  }

  /// @inheritdoc ICrossChainForwarder
  function isEnvelopeRegistered(bytes32 envelopeId) public view returns (bool) {
    return _registeredEnvelopes[envelopeId];
  }

  /// @inheritdoc ICrossChainForwarder
  function isTransactionForwarded(Transaction memory transaction) public view returns (bool) {
    return isTransactionForwarded(transaction.getId());
  }

  /// @inheritdoc ICrossChainForwarder
  function isTransactionForwarded(bytes32 transactionId) public view returns (bool) {
    return _forwardedTransactions[transactionId];
  }

  /// @inheritdoc ICrossChainForwarder
  function forwardMessage(
    uint256 destinationChainId,
    address destination,
    uint256 gasLimit,
    bytes memory message
  ) external onlyApprovedSenders returns (bytes32, bytes32) {
    ChainIdBridgeConfig[] memory bridgeAdapters = _bridgeAdaptersByChain[destinationChainId];
    require(bridgeAdapters.length > 0, Errors.NO_BRIDGE_ADAPTERS_FOR_SPECIFIED_CHAIN);

    uint256 envelopeNonce = _currentEnvelopeNonce++;

    Envelope memory envelope = Envelope({
      nonce: envelopeNonce,
      origin: msg.sender,
      destination: destination,
      originChainId: block.chainid,
      destinationChainId: destinationChainId,
      message: message
    });
    EncodedEnvelope memory encodedEnvelope = envelope.encode();
    // save accepted envelope for future retries in case one ore more bridges will not deliver the message to the destination
    _registeredEnvelopes[encodedEnvelope.id] = true;
    emit EnvelopeRegistered(encodedEnvelope.id, envelope);

    EncodedTransaction memory encodedTransaction = (
      Transaction({nonce: _currentTransactionNonce++, encodedEnvelope: encodedEnvelope.data})
    ).encode();

    _forwardedTransactions[encodedTransaction.id] = true;

    _bridgeTransaction(
      encodedEnvelope.id,
      encodedTransaction.id,
      encodedTransaction.data,
      envelope.destinationChainId,
      gasLimit,
      bridgeAdapters
    );
    return (encodedEnvelope.id, encodedTransaction.id);
  }

  /// @inheritdoc ICrossChainForwarder
  function retryEnvelope(
    Envelope memory envelope,
    uint256 gasLimit
  ) external onlyOwnerOrGuardian returns (bytes32) {
    EncodedEnvelope memory encodedEnvelope = envelope.encode();

    // Message can be retried only if it was sent before with exactly the same parameters
    require(isEnvelopeRegistered(encodedEnvelope.id), Errors.ENVELOPE_NOT_PREVIOUSLY_REGISTERED);

    ChainIdBridgeConfig[] memory bridgeAdapters = _bridgeAdaptersByChain[
      envelope.destinationChainId
    ];
    require(bridgeAdapters.length > 0, Errors.NO_BRIDGE_ADAPTERS_FOR_SPECIFIED_CHAIN);

    EncodedTransaction memory encodedTransaction = (
      Transaction({nonce: _currentTransactionNonce++, encodedEnvelope: encodedEnvelope.data})
    ).encode();

    _forwardedTransactions[encodedTransaction.id] = true;

    _bridgeTransaction(
      encodedEnvelope.id,
      encodedTransaction.id,
      encodedTransaction.data,
      envelope.destinationChainId,
      gasLimit,
      bridgeAdapters
    );

    return encodedTransaction.id;
  }

  /// @inheritdoc ICrossChainForwarder
  function retryTransaction(
    bytes memory encodedTransaction,
    uint256 gasLimit,
    address[] memory bridgeAdaptersToRetry
  ) external onlyOwnerOrGuardian {
    bytes32 transactionId = TransactionUtils.getId(encodedTransaction);
    // Transaction can be retried only if it was sent before with exactly the same parameters
    require(isTransactionForwarded(transactionId), Errors.TRANSACTION_NOT_PREVIOUSLY_FORWARDED);

    Transaction memory transaction = TransactionUtils.decode(encodedTransaction);
    Envelope memory envelope = transaction.getEnvelope();

    ChainIdBridgeConfig[] memory registeredBridgeAdapters = _bridgeAdaptersByChain[
      envelope.destinationChainId
    ];
    require(registeredBridgeAdapters.length > 0, Errors.NO_BRIDGE_ADAPTERS_FOR_SPECIFIED_CHAIN);

    ChainIdBridgeConfig[] memory bridgeAdaptersToRetryConfig = new ChainIdBridgeConfig[](
      bridgeAdaptersToRetry.length
    );

    for (uint256 i = 0; i < bridgeAdaptersToRetry.length; i++) {
      // check that we're not sending 2 times to the same adapter
      for (uint256 j = i + 1; j < bridgeAdaptersToRetry.length; j++) {
        require(
          bridgeAdaptersToRetry[i] != bridgeAdaptersToRetry[j],
          Errors.BRIDGE_ADAPTERS_SHOULD_BE_UNIQUE
        );
      }

      // check that adapter is valid for this networkId
      bool isAdapterRegistered = false;
      for (uint256 j = 0; j < registeredBridgeAdapters.length; j++) {
        if (bridgeAdaptersToRetry[i] == registeredBridgeAdapters[j].currentChainBridgeAdapter) {
          bridgeAdaptersToRetryConfig[i] = registeredBridgeAdapters[j];
          isAdapterRegistered = true;
          break;
        }
      }
      require(isAdapterRegistered, Errors.INVALID_BRIDGE_ADAPTER);
    }

    bool isBridgedAtLeastOnce = _bridgeTransaction(
      transaction.getEnvelopeId(),
      transactionId,
      encodedTransaction,
      envelope.destinationChainId,
      gasLimit,
      bridgeAdaptersToRetryConfig
    );
    require(isBridgedAtLeastOnce, Errors.TRANSACTION_RETRY_FAILED);
  }

  /// @inheritdoc ICrossChainForwarder
  function getForwarderBridgeAdaptersByChain(
    uint256 chainId
  ) external view returns (ChainIdBridgeConfig[] memory) {
    return _bridgeAdaptersByChain[chainId];
  }

  /// @inheritdoc ICrossChainForwarder
  function approveSenders(address[] memory senders) external onlyOwner {
    _updateSenders(senders, true);
  }

  /// @inheritdoc ICrossChainForwarder
  function removeSenders(address[] memory senders) external onlyOwner {
    _updateSenders(senders, false);
  }

  /// @inheritdoc ICrossChainForwarder
  function enableBridgeAdapters(
    ForwarderBridgeAdapterConfigInput[] memory bridgeAdapters
  ) external onlyOwner {
    _enableBridgeAdapters(bridgeAdapters);
  }

  /// @inheritdoc ICrossChainForwarder
  function disableBridgeAdapters(
    BridgeAdapterToDisable[] memory bridgeAdapters
  ) external onlyOwner {
    _disableBridgeAdapters(bridgeAdapters);
  }

  /**
   * @notice internal method that has the logic to forward a transaction to the specified chain
   * @param envelopeId the id of the envelope
   * @param transactionId id of the transaction to bridge
   * @param encodedTransaction the encoded Transaction data
   * @param destinationChainId id of the chain where the transaction needs to be forwarded to
   * @param gasLimit limit of gas to spend on forwarding per bridge
   * @param bridgeAdapters list of bridge adapters to be used for the transaction forwarding
   * @return flag indicating if transaction has been forwarded at least once. The transaction id
   */
  function _bridgeTransaction(
    bytes32 envelopeId,
    bytes32 transactionId,
    bytes memory encodedTransaction,
    uint256 destinationChainId,
    uint256 gasLimit,
    ChainIdBridgeConfig[] memory bridgeAdapters
  ) internal returns (bool) {
    bool isForwardedAtLeastOnce = false;
    for (uint256 i = 0; i < bridgeAdapters.length; i++) {
      (bool success, bytes memory returnData) = bridgeAdapters[i]
        .currentChainBridgeAdapter
        .delegatecall(
          abi.encodeWithSelector(
            IBaseAdapter.forwardMessage.selector,
            bridgeAdapters[i].destinationBridgeAdapter,
            gasLimit,
            destinationChainId,
            encodedTransaction
          )
        );

      if (success) {
        isForwardedAtLeastOnce = true;
      } else {
        // it doesn't revert as sending to other bridges might succeed
      }
      emit TransactionForwardingAttempted(
        transactionId,
        envelopeId,
        encodedTransaction,
        destinationChainId,
        bridgeAdapters[i].currentChainBridgeAdapter,
        bridgeAdapters[i].destinationBridgeAdapter,
        success,
        returnData
      );
    }

    return (isForwardedAtLeastOnce);
  }

  /**
   * @notice method to enable bridge adapters
   * @param bridgeAdapters array of new bridge adapter configurations
   */
  function _enableBridgeAdapters(
    ForwarderBridgeAdapterConfigInput[] memory bridgeAdapters
  ) internal {
    for (uint256 i = 0; i < bridgeAdapters.length; i++) {
      ForwarderBridgeAdapterConfigInput memory bridgeAdapterConfigInput = bridgeAdapters[i];

      require(
        bridgeAdapterConfigInput.destinationBridgeAdapter != address(0) &&
          bridgeAdapterConfigInput.currentChainBridgeAdapter != address(0),
        Errors.CURRENT_OR_DESTINATION_CHAIN_ADAPTER_NOT_SET
      );
      ChainIdBridgeConfig[] storage bridgeAdapterConfigs = _bridgeAdaptersByChain[
        bridgeAdapterConfigInput.destinationChainId
      ];
      bool configFound;
      // check that we don't push same config twice.
      for (uint256 j = 0; j < bridgeAdapterConfigs.length; j++) {
        ChainIdBridgeConfig storage bridgeAdapterConfig = bridgeAdapterConfigs[j];

        if (
          bridgeAdapterConfig.currentChainBridgeAdapter ==
          bridgeAdapterConfigInput.currentChainBridgeAdapter
        ) {
          if (
            bridgeAdapterConfig.destinationBridgeAdapter !=
            bridgeAdapterConfigInput.destinationBridgeAdapter
          ) {
            bridgeAdapterConfig.destinationBridgeAdapter = bridgeAdapterConfigInput
              .destinationBridgeAdapter;

            emit BridgeAdapterUpdated(
              bridgeAdapterConfigInput.destinationChainId,
              bridgeAdapterConfigInput.currentChainBridgeAdapter,
              bridgeAdapterConfigInput.destinationBridgeAdapter,
              true
            );
          }
          configFound = true;
          break;
        }
      }

      if (!configFound) {
        // preparing fees stream
        Address.functionDelegateCall(
          bridgeAdapterConfigInput.currentChainBridgeAdapter,
          abi.encodeWithSelector(IBaseAdapter.setupPayments.selector),
          Errors.ADAPTER_PAYMENT_SETUP_FAILED
        );

        bridgeAdapterConfigs.push(
          ChainIdBridgeConfig({
            destinationBridgeAdapter: bridgeAdapterConfigInput.destinationBridgeAdapter,
            currentChainBridgeAdapter: bridgeAdapterConfigInput.currentChainBridgeAdapter
          })
        );

        emit BridgeAdapterUpdated(
          bridgeAdapterConfigInput.destinationChainId,
          bridgeAdapterConfigInput.currentChainBridgeAdapter,
          bridgeAdapterConfigInput.destinationBridgeAdapter,
          true
        );
      }
    }
  }

  /**
   * @notice method to disable bridge adapters
   * @param bridgeAdaptersToDisable array of bridge adapter addresses to disable
   */
  function _disableBridgeAdapters(
    BridgeAdapterToDisable[] memory bridgeAdaptersToDisable
  ) internal {
    for (uint256 i = 0; i < bridgeAdaptersToDisable.length; i++) {
      for (uint256 j = 0; j < bridgeAdaptersToDisable[i].chainIds.length; j++) {
        ChainIdBridgeConfig[] storage bridgeAdapterConfigs = _bridgeAdaptersByChain[
          bridgeAdaptersToDisable[i].chainIds[j]
        ];

        for (uint256 k = 0; k < bridgeAdapterConfigs.length; k++) {
          if (
            bridgeAdapterConfigs[k].currentChainBridgeAdapter ==
            bridgeAdaptersToDisable[i].bridgeAdapter
          ) {
            address destinationBridgeAdapter = bridgeAdapterConfigs[k].destinationBridgeAdapter;

            bridgeAdapterConfigs[k] = bridgeAdapterConfigs[bridgeAdapterConfigs.length - 1];
            bridgeAdapterConfigs.pop();

            emit BridgeAdapterUpdated(
              bridgeAdaptersToDisable[i].chainIds[j],
              bridgeAdaptersToDisable[i].bridgeAdapter,
              destinationBridgeAdapter,
              false
            );
            break;
          }
        }
      }
    }
  }

  /**
   * @notice method to approve or disapprove a list of senders
   * @param senders list of addresses to update
   * @param newState indicates if the list of senders will be approved or disapproved
   */
  function _updateSenders(address[] memory senders, bool newState) internal {
    for (uint256 i = 0; i < senders.length; i++) {
      require(senders[i] != address(0), Errors.INVALID_SENDER);
      _approvedSenders[senders[i]] = newState;
      emit SenderUpdated(senders[i], newState);
    }
  }

  /// @dev utility function, defining an order of actions commonly done in batch
  function _configureForwarderBasics(
    ForwarderBridgeAdapterConfigInput[] memory bridgesToEnable,
    BridgeAdapterToDisable[] memory bridgesToDisable,
    address[] memory sendersToEnable,
    address[] memory sendersToDisable
  ) internal {
    _enableBridgeAdapters(bridgesToEnable);
    _disableBridgeAdapters(bridgesToDisable);
    _updateSenders(sendersToEnable, true);
    _updateSenders(sendersToDisable, false);
  }
}

File 16 of 26 : CrossChainReceiver.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.8;

import {OwnableWithGuardian} from 'solidity-utils/contracts/access-control/OwnableWithGuardian.sol';

import {ICrossChainReceiver, EnumerableSet} from './interfaces/ICrossChainReceiver.sol';
import {IBaseReceiverPortal} from './interfaces/IBaseReceiverPortal.sol';
import {Transaction, Envelope, TransactionUtils} from './libs/EncodingUtils.sol';
import {Errors} from './libs/Errors.sol';

/**
 * @title CrossChainReceiver
 * @author BGD Labs
 * @notice this contract contains the methods to get bridged messages and route them to their respective recipients.
 * @dev to route a message, this one needs to be bridged correctly n number of confirmations.
 * @dev if at some point, it is detected that some bridge has been hacked, there is a possibility to invalidate
 *      messages by calling updateMessagesValidityTimestamp
 */
contract CrossChainReceiver is OwnableWithGuardian, ICrossChainReceiver {
  using EnumerableSet for EnumerableSet.AddressSet;
  using EnumerableSet for EnumerableSet.UintSet;

  // chainId => configuration
  mapping(uint256 => ReceiverConfigurationFull) internal _configurationsByChain;

  // stores hash(Transaction) => bridged transaction information and state
  mapping(bytes32 => TransactionState) internal _transactionsState;

  // stores hash(Envelope) => received envelope state
  mapping(bytes32 => EnvelopeState) internal _envelopesState;

  // stores the currently supported chains (chains that have at least 1 bridge adapter)
  EnumerableSet.UintSet internal _supportedChains;

  // storage gap allocation to be used for later updates. This way storage can be added on parent contract without
  // overwriting storage on child
  uint256[50] private __RECEIVER_GAP;

  // checks if caller is one of the approved bridge adapters
  modifier onlyApprovedBridges(uint256 chainId) {
    require(isReceiverBridgeAdapterAllowed(msg.sender, chainId), Errors.CALLER_NOT_APPROVED_BRIDGE);
    _;
  }

  /**
   * @param initialRequiredConfirmations number of confirmations the messages need to be accepted as valid
   * @param bridgeAdaptersToAllow array of objects containing the chain and address of the bridge adapters that
            can receive messages
   */
  constructor(
    ConfirmationInput[] memory initialRequiredConfirmations,
    ReceiverBridgeAdapterConfigInput[] memory bridgeAdaptersToAllow
  ) {
    _configureReceiverBasics(
      bridgeAdaptersToAllow,
      new ReceiverBridgeAdapterConfigInput[](0),
      initialRequiredConfirmations
    );
  }

  /// @inheritdoc ICrossChainReceiver
  function getReceiverBridgeAdaptersByChain(
    uint256 chainId
  ) public view returns (address[] memory) {
    return _configurationsByChain[chainId].allowedBridgeAdapters.values();
  }

  /// @inheritdoc ICrossChainReceiver
  function getSupportedChains() external view returns (uint256[] memory) {
    return _supportedChains.values();
  }

  /// @inheritdoc ICrossChainReceiver
  function getConfigurationByChain(
    uint256 chainId
  ) external view returns (ReceiverConfiguration memory) {
    return _configurationsByChain[chainId].configuration;
  }

  /// @inheritdoc ICrossChainReceiver
  function isReceiverBridgeAdapterAllowed(
    address bridgeAdapter,
    uint256 chainId
  ) public view returns (bool) {
    return _configurationsByChain[chainId].allowedBridgeAdapters.contains(bridgeAdapter);
  }

  /// @inheritdoc ICrossChainReceiver
  function getTransactionState(
    bytes32 transactionId
  ) public view returns (TransactionStateWithoutAdapters memory) {
    return
      TransactionStateWithoutAdapters({
        confirmations: _transactionsState[transactionId].confirmations,
        firstBridgedAt: _transactionsState[transactionId].firstBridgedAt
      });
  }

  /// @inheritdoc ICrossChainReceiver
  function getTransactionState(
    Transaction memory transaction
  ) external view returns (TransactionStateWithoutAdapters memory) {
    return getTransactionState(transaction.getId());
  }

  /// @inheritdoc ICrossChainReceiver
  function getEnvelopeState(Envelope memory envelope) external view returns (EnvelopeState) {
    return getEnvelopeState(envelope.getId());
  }

  /// @inheritdoc ICrossChainReceiver
  function getEnvelopeState(bytes32 envelopeId) public view returns (EnvelopeState) {
    return _envelopesState[envelopeId];
  }

  /// @inheritdoc ICrossChainReceiver
  function isTransactionReceivedByAdapter(
    bytes32 transactionId,
    address bridgeAdapter
  ) external view returns (bool) {
    return _transactionsState[transactionId].bridgedByAdapter[bridgeAdapter];
  }

  /// @inheritdoc ICrossChainReceiver
  function updateConfirmations(ConfirmationInput[] memory newConfirmations) external onlyOwner {
    _updateConfirmations(newConfirmations);
  }

  /// @inheritdoc ICrossChainReceiver
  function updateMessagesValidityTimestamp(
    ValidityTimestampInput[] memory newValidityTimestamp
  ) external onlyOwner {
    _updateMessagesValidityTimestamp(newValidityTimestamp);
  }

  /// @inheritdoc ICrossChainReceiver
  function allowReceiverBridgeAdapters(
    ReceiverBridgeAdapterConfigInput[] memory bridgeAdaptersInput
  ) external onlyOwner {
    _updateReceiverBridgeAdapters(bridgeAdaptersInput, true);
  }

  /// @inheritdoc ICrossChainReceiver
  function disallowReceiverBridgeAdapters(
    ReceiverBridgeAdapterConfigInput[] memory bridgeAdapters
  ) external onlyOwner {
    _updateReceiverBridgeAdapters(bridgeAdapters, false);
  }

  /// @inheritdoc ICrossChainReceiver
  function receiveCrossChainMessage(
    bytes memory encodedTransaction,
    uint256 originChainId
  ) external onlyApprovedBridges(originChainId) {
    Transaction memory transaction = TransactionUtils.decode(encodedTransaction);
    Envelope memory envelope = transaction.getEnvelope();
    require(
      envelope.originChainId == originChainId && envelope.destinationChainId == block.chainid,
      Errors.CHAIN_ID_MISMATCH
    );
    bytes32 envelopeId = transaction.getEnvelopeId();

    bytes32 transactionId = TransactionUtils.getId(encodedTransaction);

    TransactionState storage internalTransaction = _transactionsState[transactionId];
    ReceiverConfiguration memory configuration = _configurationsByChain[originChainId]
      .configuration;

    // If bridged at is > invalidation, it means that the first time transaction was received after last invalidation and
    // can be processed.
    // 0 here means that it’s received for a first time, so invalidation does not matter for this message.
    // Also checks that bridge adapter didn’t bridge this transaction already.
    // Dont let messages pass if required confirmations are 0. Meaning that they have not been configured
    uint120 transactionFirstBridgedAt = internalTransaction.firstBridgedAt;
    if (
      transactionFirstBridgedAt == 0 ||
      (!internalTransaction.bridgedByAdapter[msg.sender] &&
        transactionFirstBridgedAt > configuration.validityTimestamp)
    ) {
      if (transactionFirstBridgedAt == 0) {
        internalTransaction.firstBridgedAt = uint120(block.timestamp);
      }

      uint8 newConfirmations = ++internalTransaction.confirmations;
      internalTransaction.bridgedByAdapter[msg.sender] = true;

      emit TransactionReceived(
        transactionId,
        envelopeId,
        originChainId,
        transaction,
        msg.sender,
        newConfirmations
      );
      // Checks that the message was not confirmed and/or delivered before, so it will not try to deliver again when message arrives
      // from additional bridges after reaching required number of confirmations
      if (_envelopesState[envelopeId] != EnvelopeState.None) {
        return;
      }

      // >= is used for the case when confirmations gets lowered before message reached the old _requiredConfirmations
      // but on receiving new messages it surpasses the current _requiredConfirmations. So it doesn't get stuck (if using ==)
      if (
        configuration.requiredConfirmation > 0 &&
        newConfirmations >= configuration.requiredConfirmation
      ) {
        _envelopesState[envelopeId] = EnvelopeState.Delivered;
        try
          IBaseReceiverPortal(envelope.destination).receiveCrossChainMessage(
            envelope.origin,
            envelope.originChainId,
            envelope.message
          )
        {
          emit EnvelopeDeliveryAttempted(envelopeId, envelope, true);
        } catch (bytes memory) {
          _envelopesState[envelopeId] = EnvelopeState.Confirmed;
          emit EnvelopeDeliveryAttempted(envelopeId, envelope, false);
        }
      }
    }
  }

  /// @inheritdoc ICrossChainReceiver
  function deliverEnvelope(Envelope memory envelope) external {
    bytes32 envelopeId = envelope.getId();
    require(
      _envelopesState[envelopeId] == EnvelopeState.Confirmed,
      Errors.ENVELOPE_NOT_CONFIRMED_OR_DELIVERED
    );

    _envelopesState[envelopeId] = EnvelopeState.Delivered;
    IBaseReceiverPortal(envelope.destination).receiveCrossChainMessage(
      envelope.origin,
      envelope.originChainId,
      envelope.message
    );
    emit EnvelopeDeliveryAttempted(envelopeId, envelope, true);
  }

  /**
   * @notice method to set a new timestamp from where the messages will be valid.
   * @param newValidityTimestampsInput array of objects containing the chain and timestamp where all the previous unconfirmed
            messages must be invalidated.
   */
  function _updateMessagesValidityTimestamp(
    ValidityTimestampInput[] memory newValidityTimestampsInput
  ) internal {
    for (uint256 i; i < newValidityTimestampsInput.length; i++) {
      ValidityTimestampInput memory input = newValidityTimestampsInput[i];
      require(
        input.validityTimestamp >
          _configurationsByChain[input.chainId].configuration.validityTimestamp &&
          input.validityTimestamp <= block.timestamp,
        Errors.INVALID_VALIDITY_TIMESTAMP
      );
      _configurationsByChain[input.chainId].configuration.validityTimestamp = input
        .validityTimestamp;

      emit NewInvalidation(input.validityTimestamp, input.chainId);
    }
  }

  /**
   * @notice method to update the number of confirmations necessary for the messages to be accepted as valid
   * @param newConfirmations array of objects with the chainId and the new number of needed confirmations
   */
  function _updateConfirmations(ConfirmationInput[] memory newConfirmations) internal {
    for (uint256 i; i < newConfirmations.length; i++) {
      ConfirmationInput memory confirmations = newConfirmations[i];
      require(
        confirmations.requiredConfirmations > 0 &&
          confirmations.requiredConfirmations <=
          _configurationsByChain[confirmations.chainId].allowedBridgeAdapters.length(),
        Errors.INVALID_REQUIRED_CONFIRMATIONS
      );
      _configurationsByChain[confirmations.chainId]
        .configuration
        .requiredConfirmation = confirmations.requiredConfirmations;
      emit ConfirmationsUpdated(confirmations.requiredConfirmations, confirmations.chainId);
    }
  }

  /**
   * @notice method to add bridge adapters to the allowed list
   * @param bridgeAdaptersInput array of objects with the new bridge adapters and supported chains
   */
  function _updateReceiverBridgeAdapters(
    ReceiverBridgeAdapterConfigInput[] memory bridgeAdaptersInput,
    bool isAllowed
  ) internal {
    for (uint256 i = 0; i < bridgeAdaptersInput.length; i++) {
      ReceiverBridgeAdapterConfigInput memory input = bridgeAdaptersInput[i];
      require(input.bridgeAdapter != address(0), Errors.INVALID_BRIDGE_ADAPTER);

      for (uint256 j; j < input.chainIds.length; j++) {
        bool actionProcessed;
        if (isAllowed) {
          _supportedChains.add(input.chainIds[j]);
          actionProcessed = _configurationsByChain[input.chainIds[j]].allowedBridgeAdapters.add(
            input.bridgeAdapter
          );
        } else {
          actionProcessed = _configurationsByChain[input.chainIds[j]].allowedBridgeAdapters.remove(
            input.bridgeAdapter
          );
          if (
            actionProcessed &&
            _configurationsByChain[input.chainIds[j]].allowedBridgeAdapters.length() == 0
          ) {
            _supportedChains.remove(input.chainIds[j]);
          }
        }
        if (actionProcessed) {
          emit ReceiverBridgeAdaptersUpdated(input.bridgeAdapter, isAllowed, input.chainIds[j]);
        }
      }
    }
  }

  /// @dev utility function, defining an order of actions commonly done in batch
  function _configureReceiverBasics(
    ReceiverBridgeAdapterConfigInput[] memory bridgesToEnable,
    ReceiverBridgeAdapterConfigInput[] memory bridgesToDisable,
    ConfirmationInput[] memory newConfirmations
  ) internal {
    // IMPORTANT. Confirmations update should always happen after adapters, to not create a situation of
    // blockage in the system
    _updateReceiverBridgeAdapters(bridgesToEnable, true);
    _updateReceiverBridgeAdapters(bridgesToDisable, false);
    _updateConfirmations(newConfirmations);
  }
}

File 17 of 26 : IBaseAdapter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IBaseCrossChainController} from '../interfaces/IBaseCrossChainController.sol';

/**
 * @title IBaseAdapter
 * @author BGD Labs
 * @notice interface containing the event and method used in all bridge adapters
 */
interface IBaseAdapter {
  /**
   * @notice emitted when a trusted remote is set
   * @param originChainId id of the chain where the trusted remote is from
   * @param originForwarder address of the contract that will send the messages
   */
  event SetTrustedRemote(uint256 originChainId, address originForwarder);

  /**
   * @notice pair of origin address and origin chain
   * @param originForwarder address of the contract that will send the messages
   * @param originChainId id of the chain where the trusted remote is from
   */
  struct TrustedRemotesConfig {
    address originForwarder;
    uint256 originChainId;
  }

  /**
   * @notice method that will bridge the payload to the chain specified
   * @param receiver address of the receiver contract on destination chain
   * @param executionGasLimit amount of the gas limit in wei to use for delivering the message on destination network.
            Each adapter will manage this as needed.
   * @param destinationChainId id of the destination chain in the bridge notation
   * @param message to send to the specified chain
   * @return the third-party bridge entrypoint, the third-party bridge message id
   */
  function forwardMessage(
    address receiver,
    uint256 executionGasLimit,
    uint256 destinationChainId,
    bytes calldata message
  ) external returns (address, uint256);

  /**
   * @notice method to get the address of the linked cross chain controller
   * @return address of CrossChainController
   */
  function CROSS_CHAIN_CONTROLLER() external returns (IBaseCrossChainController);

  /**
   * @notice method to get the name of the adapter contract
   * @return name of the adapter contract
   */
  function adapterName() external view returns (string memory);

  /**
   * @notice method to get the base gas limit used by the bridge adapter
   */
  function BASE_GAS_LIMIT() external returns (uint256);

  /**
   * @notice method used to setup payment, ie grant approvals over tokens used to pay for tx fees
   */
  function setupPayments() external;

  /**
   * @notice method to get the trusted remote address from a specified chain id
   * @param chainId id of the chain from where to get the trusted remote
   * @return address of the trusted remote
   */
  function getTrustedRemoteByChainId(uint256 chainId) external view returns (address);

  /**
   * @notice method to get infrastructure chain id from bridge native chain id
   * @param bridgeChainId bridge native chain id
   */
  function nativeToInfraChainId(uint256 bridgeChainId) external returns (uint256);

  /**
   * @notice method to get bridge native chain id from native bridge chain id
   * @param infraChainId infrastructure chain id
   */
  function infraToNativeChainId(uint256 infraChainId) external returns (uint256);
}

File 18 of 26 : IBaseCrossChainController.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './ICrossChainForwarder.sol';
import './ICrossChainReceiver.sol';
import {IRescuable} from 'solidity-utils/contracts/utils/interfaces/IRescuable.sol';

/**
 * @title IBaseCrossChainController
 * @author BGD Labs
 * @notice interface containing the objects, events and methods definitions of the CrossChainController contract
 */
interface IBaseCrossChainController is IRescuable, ICrossChainForwarder, ICrossChainReceiver {

}

File 19 of 26 : IBaseReceiverPortal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title IBaseReceiverPortal
 * @author BGD Labs
 * @notice interface defining the method that needs to be implemented by all receiving portals, as its the one that
           will be called when a received message gets confirmed
 */
interface IBaseReceiverPortal {
  /**
   * @notice method called by CrossChainController when a message has been confirmed
   * @param originSender address of the sender of the bridged message
   * @param originChainId id of the chain where the message originated
   * @param message bytes bridged containing the desired information
   */
  function receiveCrossChainMessage(
    address originSender,
    uint256 originChainId,
    bytes memory message
  ) external;
}

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

import './IBaseCrossChainController.sol';

/**
 * @title ICrossChainController
 * @author BGD Labs
 * @notice interface containing the objects, events and methods definitions of the ICrossChainControllerMainnet contract
 */
interface ICrossChainController is IBaseCrossChainController {
  /**
   * @notice method called to initialize the proxy
   * @param owner address of the owner of the cross chain controller
   * @param guardian address of the guardian of the cross chain controller
   * @param initialRequiredConfirmations number of confirmations the messages need to be accepted as valid
   * @param receiverBridgeAdaptersToAllow array of addresses of the bridge adapters that can receive messages
   * @param forwarderBridgeAdaptersToEnable array specifying for every bridgeAdapter, the destinations it can have
   * @param sendersToApprove array of addresses to allow as forwarders
   */
  function initialize(
    address owner,
    address guardian,
    ConfirmationInput[] memory initialRequiredConfirmations,
    ReceiverBridgeAdapterConfigInput[] memory receiverBridgeAdaptersToAllow,
    ForwarderBridgeAdapterConfigInput[] memory forwarderBridgeAdaptersToEnable,
    address[] memory sendersToApprove
  ) external;
}

File 21 of 26 : ICrossChainForwarder.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

import {Transaction, Envelope} from '../libs/EncodingUtils.sol';

/**
 * @title ICrossChainForwarder
 * @author BGD Labs
 * @notice interface containing the objects, events and methods definitions of the CrossChainForwarder contract
 */
interface ICrossChainForwarder {
  /**
   * @notice object storing the connected pair of bridge adapters, on current and destination chain
   * @param destinationBridgeAdapter address of the bridge adapter on the destination chain
   * @param currentChainBridgeAdapter address of the bridge adapter deployed on current network
   */
  struct ChainIdBridgeConfig {
    address destinationBridgeAdapter;
    address currentChainBridgeAdapter;
  }

  /**
   * @notice object with the necessary information to remove bridge adapters
   * @param bridgeAdapter address of the bridge adapter to remove
   * @param chainIds array of chain ids where the bridge adapter connects
   */
  struct BridgeAdapterToDisable {
    address bridgeAdapter;
    uint256[] chainIds;
  }

  /**
   * @notice object storing the pair bridgeAdapter (current deployed chain) destination chain bridge adapter configuration
   * @param currentChainBridgeAdapter address of the bridge adapter deployed on current chain
   * @param destinationBridgeAdapter address of the bridge adapter on the destination chain
   * @param destinationChainId id of the destination chain using our own nomenclature
   */
  struct ForwarderBridgeAdapterConfigInput {
    address currentChainBridgeAdapter;
    address destinationBridgeAdapter;
    uint256 destinationChainId;
  }

  /**
   * @notice emitted when a transaction is successfully forwarded through a bridge adapter
   * @param envelopeId internal id of the envelope
   * @param envelope the Envelope type data
   */
  event EnvelopeRegistered(bytes32 indexed envelopeId, Envelope envelope);

  /**
   * @notice emitted when a transaction forwarding is attempted through a bridge adapter
   * @param transactionId id of the forwarded transaction
   * @param envelopeId internal id of the envelope
   * @param encodedTransaction object intended to be bridged
   * @param destinationChainId id of the destination chain in our notation
   * @param bridgeAdapter address of the bridge adapter that failed (deployed on current network)
   * @param destinationBridgeAdapter address of the connected bridge adapter on destination chain
   * @param adapterSuccessful adapter was able to forward the message
   * @param returnData bytes with error information
   */
  event TransactionForwardingAttempted(
    bytes32 transactionId,
    bytes32 indexed envelopeId,
    bytes encodedTransaction,
    uint256 destinationChainId,
    address indexed bridgeAdapter,
    address destinationBridgeAdapter,
    bool indexed adapterSuccessful,
    bytes returnData
  );

  /**
   * @notice emitted when a bridge adapter has been added to the allowed list
   * @param destinationChainId id of the destination chain in our notation
   * @param bridgeAdapter address of the bridge adapter added (deployed on current network)
   * @param destinationBridgeAdapter address of the connected bridge adapter on destination chain
   * @param allowed boolean indicating if the bridge adapter is allowed or disallowed
   */
  event BridgeAdapterUpdated(
    uint256 indexed destinationChainId,
    address indexed bridgeAdapter,
    address destinationBridgeAdapter,
    bool indexed allowed
  );

  /**
   * @notice emitted when a sender has been updated
   * @param sender address of the updated sender
   * @param isApproved boolean that indicates if the sender has been approved or removed
   */
  event SenderUpdated(address indexed sender, bool indexed isApproved);

  /**
   * @notice method to get the current valid envelope nonce
   * @return the current valid envelope nonce
   */
  function getCurrentEnvelopeNonce() external view returns (uint256);

  /**
   * @notice method to get the current valid transaction nonce
   * @return the current valid transaction nonce
   */
  function getCurrentTransactionNonce() external view returns (uint256);

  /**
   * @notice method to check if a envelope has been previously forwarded.
   * @param envelope the Envelope type data
   * @return boolean indicating if the envelope has been registered
   */
  function isEnvelopeRegistered(Envelope memory envelope) external view returns (bool);

  /**
   * @notice method to check if a envelope has been previously forwarded.
   * @param envelopeId the hashed id of the envelope
   * @return boolean indicating if the envelope has been registered
   */
  function isEnvelopeRegistered(bytes32 envelopeId) external view returns (bool);

  /**
   * @notice method to get if a transaction has been forwarded
   * @param transaction the Transaction type data
   * @return flag indicating if a transaction has been forwarded
   */
  function isTransactionForwarded(Transaction memory transaction) external view returns (bool);

  /**
   * @notice method to get if a transaction has been forwarded
   * @param transactionId hashed id of the transaction
   * @return flag indicating if a transaction has been forwarded
   */
  function isTransactionForwarded(bytes32 transactionId) external view returns (bool);

  /**
   * @notice method called to initiate message forwarding to other networks.
   * @param destinationChainId id of the destination chain where the message needs to be bridged
   * @param destination address where the message is intended for
   * @param gasLimit gas cost on receiving side of the message
   * @param message bytes that need to be bridged
   * @return internal id of the envelope and transaction
   */
  function forwardMessage(
    uint256 destinationChainId,
    address destination,
    uint256 gasLimit,
    bytes memory message
  ) external returns (bytes32, bytes32);

  /**
   * @notice method called to re forward a previously sent envelope.
   * @param envelope the Envelope type data
   * @param gasLimit gas cost on receiving side of the message
   * @return the transaction id that has the retried envelope
   * @dev This method will send an existing Envelope using a new Transaction.
   * @dev This method should be used when the intention is to send the Envelope as if it was a new message. This way on
          the Receiver side it will start from 0 to count for the required confirmations. (usual use case would be for
          when an envelope has been invalidated on Receiver side, and needs to be retried as a new message)
   */
  function retryEnvelope(Envelope memory envelope, uint256 gasLimit) external returns (bytes32);

  /**
   * @notice method to retry forwarding an already forwarded transaction
   * @param encodedTransaction the encoded Transaction data
   * @param gasLimit limit of gas to spend on forwarding per bridge
   * @param bridgeAdaptersToRetry list of bridge adapters to be used for the transaction forwarding retry
   * @dev This method will send an existing Transaction with its Envelope to the specified adapters.
   * @dev Should be used when some of the bridges on the initial forwarding did not work (out of gas),
          and we want the Transaction with Envelope to still account for the required confirmations on the Receiver side
   */
  function retryTransaction(
    bytes memory encodedTransaction,
    uint256 gasLimit,
    address[] memory bridgeAdaptersToRetry
  ) external;

  /**
   * @notice method to enable bridge adapters
   * @param bridgeAdapters array of new bridge adapter configurations
   */
  function enableBridgeAdapters(ForwarderBridgeAdapterConfigInput[] memory bridgeAdapters) external;

  /**
   * @notice method to disable bridge adapters
   * @param bridgeAdapters array of bridge adapter addresses to disable
   */
  function disableBridgeAdapters(BridgeAdapterToDisable[] memory bridgeAdapters) external;

  /**
   * @notice method to remove sender addresses
   * @param senders list of addresses to remove
   */
  function removeSenders(address[] memory senders) external;

  /**
   * @notice method to approve new sender addresses
   * @param senders list of addresses to approve
   */
  function approveSenders(address[] memory senders) external;

  /**
   * @notice method to get all the forwarder bridge adapters of a chain
   * @param chainId id of the chain we want to get the adapters from
   * @return an array of chain configurations where the bridge adapter can communicate
   */
  function getForwarderBridgeAdaptersByChain(
    uint256 chainId
  ) external view returns (ChainIdBridgeConfig[] memory);

  /**
   * @notice method to get if a sender is approved
   * @param sender address that we want to check if approved
   * @return boolean indicating if the address has been approved as sender
   */
  function isSenderApproved(address sender) external view returns (bool);
}

File 22 of 26 : ICrossChainReceiver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

import {EnumerableSet} from 'openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol';
import {Transaction, Envelope} from '../libs/EncodingUtils.sol';

/**
 * @title ICrossChainReceiver
 * @author BGD Labs
 * @notice interface containing the objects, events and methods definitions of the CrossChainReceiver contract
 */
interface ICrossChainReceiver {
  /**
   * @notice object with information to set new required confirmations
   * @param chainId id of the origin chain
   * @param requiredConfirmations required confirmations to set a message as confirmed
   */
  struct ConfirmationInput {
    uint256 chainId;
    uint8 requiredConfirmations;
  }

  /**
   * @notice object with information to set new validity timestamp
   * @param chainId id of the origin chain
   * @param validityTimestamp new timestamp in seconds to set as validity point
   */
  struct ValidityTimestampInput {
    uint256 chainId;
    uint120 validityTimestamp;
  }

  /**
   * @notice object with necessary information to configure bridge adapters
   * @param bridgeAdapter address of the bridge adapter to configure
   * @param chainIds array of ids of the chains the adapter receives messages from
   */
  struct ReceiverBridgeAdapterConfigInput {
    address bridgeAdapter;
    uint256[] chainIds;
  }

  /**
   * @notice object containing the receiver configuration
   * @param requiredConfirmation number of bridges that are needed to make a bridged message valid from origin chain
   * @param validityTimestamp all messages originated but not finally confirmed before this timestamp per origin chain, are invalid
   */
  struct ReceiverConfiguration {
    uint8 requiredConfirmation;
    uint120 validityTimestamp;
  }

  /**
   * @notice object with full information of the receiver configuration for a chain
   * @param configuration object containing the specifications of the receiver for a chain
   * @param allowedBridgeAdapters stores if a bridge adapter is allowed for a chain
   */
  struct ReceiverConfigurationFull {
    ReceiverConfiguration configuration;
    EnumerableSet.AddressSet allowedBridgeAdapters;
  }

  /**
   * @notice object that stores the internal information of the transaction
   * @param confirmations number of times that this transaction has been bridged
   * @param firstBridgedAt timestamp in seconds indicating the first time a transaction was received
   */
  struct TransactionStateWithoutAdapters {
    uint8 confirmations;
    uint120 firstBridgedAt;
  }
  /**
   * @notice object that stores the internal information of the transaction with bridge adapters state
   * @param confirmations number of times that this transactions has been bridged
   * @param firstBridgedAt timestamp in seconds indicating the first time a transaction was received
   * @param bridgedByAdapter list of bridge adapters that have bridged the message
   */
  struct TransactionState {
    uint8 confirmations;
    uint120 firstBridgedAt;
    mapping(address => bool) bridgedByAdapter;
  }

  /**
   * @notice object with the current state of an envelope
   * @param confirmed boolean indicating if the bridged message has been confirmed by the infrastructure
   * @param delivered boolean indicating if the bridged message has been delivered to the destination
   */
  enum EnvelopeState {
    None,
    Confirmed,
    Delivered
  }

  /**
   * @notice emitted when a transaction has been received successfully
   * @param transactionId id of the transaction
   * @param envelopeId id of the envelope
   * @param originChainId id of the chain where the envelope originated
   * @param transaction the Transaction type data
   * @param bridgeAdapter address of the bridge adapter who received the message (deployed on current network)
   * @param confirmations number of current confirmations for this message
   */
  event TransactionReceived(
    bytes32 transactionId,
    bytes32 indexed envelopeId,
    uint256 indexed originChainId,
    Transaction transaction,
    address indexed bridgeAdapter,
    uint8 confirmations
  );

  /**
   * @notice emitted when an envelope has been delivery attempted
   * @param envelopeId id of the envelope
   * @param envelope the Envelope type data
   * @param isDelivered flag indicating if the message has been delivered successfully
   */
  event EnvelopeDeliveryAttempted(bytes32 envelopeId, Envelope envelope, bool isDelivered);

  /**
   * @notice emitted when a bridge adapter gets updated (allowed or disallowed)
   * @param bridgeAdapter address of the updated bridge adapter
   * @param allowed boolean indicating if the bridge adapter has been allowed or disallowed
   * @param chainId id of the chain updated
   */
  event ReceiverBridgeAdaptersUpdated(
    address indexed bridgeAdapter,
    bool indexed allowed,
    uint256 indexed chainId
  );

  /**
   * @notice emitted when number of confirmations needed to validate a message changes
   * @param newConfirmations number of new confirmations needed for a message to be valid
   * @param chainId id of the chain updated
   */
  event ConfirmationsUpdated(uint8 newConfirmations, uint256 indexed chainId);

  /**
   * @notice emitted when a new timestamp for invalidations gets set
   * @param invalidTimestamp timestamp to invalidate previous messages
   * @param chainId id of the chain updated
   */
  event NewInvalidation(uint256 invalidTimestamp, uint256 indexed chainId);

  /**
   * @notice method to get the current allowed receiver bridge adapters for a chain
   * @param chainId id of the chain to get the allowed bridge adapter list
   * @return the list of allowed bridge adapters
   */
  function getReceiverBridgeAdaptersByChain(
    uint256 chainId
  ) external view returns (address[] memory);

  /**
   * @notice method to get the current supported chains (at least one allowed bridge adapter)
   * @return list of supported chains
   */
  function getSupportedChains() external view returns (uint256[] memory);

  /**
   * @notice method to get the current configuration of a chain
   * @param chainId id of the chain to get the configuration from
   * @return the specified chain configuration object
   */
  function getConfigurationByChain(
    uint256 chainId
  ) external view returns (ReceiverConfiguration memory);

  /**
   * @notice method to get if a bridge adapter is allowed
   * @param bridgeAdapter address of the bridge adapter to check
   * @param chainId id of the chain to check
   * @return boolean indicating if bridge adapter is allowed
   */
  function isReceiverBridgeAdapterAllowed(
    address bridgeAdapter,
    uint256 chainId
  ) external view returns (bool);

  /**
   * @notice  method to get the current state of a transaction
   * @param transactionId the id of transaction
   * @return number of confirmations of internal message identified by the transactionId and the updated timestamp
   */
  function getTransactionState(
    bytes32 transactionId
  ) external view returns (TransactionStateWithoutAdapters memory);

  /**
   * @notice  method to get the internal transaction information
   * @param transaction Transaction type data
   * @return number of confirmations of internal message identified by internalId and the updated timestamp
   */
  function getTransactionState(
    Transaction memory transaction
  ) external view returns (TransactionStateWithoutAdapters memory);

  /**
   * @notice method to get the internal state of an envelope
   * @param envelope the Envelope type data
   * @return the envelope current state, containing if it has been confirmed and delivered
   */
  function getEnvelopeState(Envelope memory envelope) external view returns (EnvelopeState);

  /**
   * @notice method to get the internal state of an envelope
   * @param envelopeId id of the envelope
   * @return the envelope current state, containing if it has been confirmed and delivered
   */
  function getEnvelopeState(bytes32 envelopeId) external view returns (EnvelopeState);

  /**
   * @notice method to get if transaction has been received by bridge adapter
   * @param transactionId id of the transaction as stored internally
   * @param bridgeAdapter address of the bridge adapter to check if it has bridged the message
   * @return boolean indicating if the message has been received
   */
  function isTransactionReceivedByAdapter(
    bytes32 transactionId,
    address bridgeAdapter
  ) external view returns (bool);

  /**
   * @notice method to set a new timestamp from where the messages will be valid.
   * @param newValidityTimestamp array of objects containing the chain and timestamp where all the previous unconfirmed
            messages must be invalidated.
   */
  function updateMessagesValidityTimestamp(
    ValidityTimestampInput[] memory newValidityTimestamp
  ) external;

  /**
   * @notice method to update the number of confirmations necessary for the messages to be accepted as valid
   * @param newConfirmations array of objects with the chainId and the new number of needed confirmations
   */
  function updateConfirmations(ConfirmationInput[] memory newConfirmations) external;

  /**
   * @notice method that receives a bridged transaction and tries to deliver the contents to destination if possible
   * @param encodedTransaction bytes containing the bridged information
   * @param originChainId id of the chain where the transaction originated
   */
  function receiveCrossChainMessage(
    bytes memory encodedTransaction,
    uint256 originChainId
  ) external;

  /**
   * @notice method to deliver an envelope to its destination
   * @param envelope the Envelope typed data
   * @dev to deliver an envelope, it needs to have been previously confirmed and not delivered
   */
  function deliverEnvelope(Envelope memory envelope) external;

  /**
   * @notice method to add bridge adapters to the allowed list
   * @param bridgeAdaptersInput array of objects with the new bridge adapters and supported chains
   */
  function allowReceiverBridgeAdapters(
    ReceiverBridgeAdapterConfigInput[] memory bridgeAdaptersInput
  ) external;

  /**
   * @notice method to remove bridge adapters from the allowed list
   * @param bridgeAdaptersInput array of objects with the bridge adapters and supported chains to disallow
   */
  function disallowReceiverBridgeAdapters(
    ReceiverBridgeAdapterConfigInput[] memory bridgeAdaptersInput
  ) external;
}

File 23 of 26 : EncodingUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

using EnvelopeUtils for Envelope global;
using TransactionUtils for Transaction global;

/**
 * @notice Object with the necessary information to define a unique envelope
 * @param nonce sequential (unique) numeric indicator of the Envelope creation
 * @param origin address that originated the bridging of a message
 * @param destination address where the message needs to be sent
 * @param originChainId id of the chain where the message originated
 * @param destinationChainId id of the chain where the message needs to be bridged
 * @param message bytes that needs to be bridged
 */
struct Envelope {
  uint256 nonce;
  address origin;
  address destination;
  uint256 originChainId;
  uint256 destinationChainId;
  bytes message;
}

/**
 * @notice Object containing the information of an envelope for internal usage
 * @param data bytes of the encoded envelope
 * @param id hash of the encoded envelope
 */
struct EncodedEnvelope {
  bytes data;
  bytes32 id;
}

/**
 * @title EnvelopeUtils library
 * @author BGD Labs
 * @notice Defines utility functions for Envelopes
 */
library EnvelopeUtils {
  /**
   * @notice method that encodes an Envelope and generates its id
   * @param envelope object with the routing information necessary to send a message to a destination chain
   * @return object containing the encoded envelope and the envelope id
   */
  function encode(Envelope memory envelope) internal pure returns (EncodedEnvelope memory) {
    EncodedEnvelope memory encodedEnvelope;
    encodedEnvelope.data = abi.encode(envelope);
    encodedEnvelope.id = getId(encodedEnvelope.data);
    return encodedEnvelope;
  }

  /**
   * @notice method to decode and encoded envelope to its raw parameters
   * @param envelope bytes with the encoded envelope data
   * @return object with the decoded envelope information
   */
  function decode(bytes memory envelope) internal pure returns (Envelope memory) {
    return abi.decode(envelope, (Envelope));
  }

  /**
   * @notice method to get an envelope's id
   * @param envelope object with the routing information necessary to send a message to a destination chain
   * @return hash id of the envelope
   */
  function getId(Envelope memory envelope) internal pure returns (bytes32) {
    EncodedEnvelope memory encodedEnvelope = encode(envelope);
    return encodedEnvelope.id;
  }

  /**
   * @notice method to get an envelope's id
   * @param envelope bytes with the encoded envelope data
   * @return hash id of the envelope
   */
  function getId(bytes memory envelope) internal pure returns (bytes32) {
    return keccak256(envelope);
  }
}

/**
 * @notice Object with the necessary information to send an envelope to a bridge
 * @param nonce sequential (unique) numeric indicator of the Transaction creation
 * @param encodedEnvelope bytes of an encoded envelope object
 */
struct Transaction {
  uint256 nonce;
  bytes encodedEnvelope;
}

/**
 * @notice Object containing the information of a transaction for internal usage
 * @param data bytes of the encoded transaction
 * @param id hash of the encoded transaction
 */
struct EncodedTransaction {
  bytes data;
  bytes32 id;
}

/**
 * @title TransactionUtils library
 * @author BGD Labs
 * @notice Defines utility functions for Transactions
 */
library TransactionUtils {
  /**
   * @notice method that encodes a Transaction and generates its id
   * @param transaction object with the information necessary to send an envelope to a bridge
   * @return object containing the encoded transaction and the transaction id
   */
  function encode(
    Transaction memory transaction
  ) internal pure returns (EncodedTransaction memory) {
    EncodedTransaction memory encodedTransaction;
    encodedTransaction.data = abi.encode(transaction);
    encodedTransaction.id = getId(encodedTransaction.data);
    return encodedTransaction;
  }

  /**
   * @notice method that decodes an encoded transaction (bytes) into a Transaction object
   * @param transaction encoded transaction object
   * @return object containing the decoded Transaction object
   */
  function decode(bytes memory transaction) internal pure returns (Transaction memory) {
    return abi.decode(transaction, (Transaction));
  }

  /**
   * @notice method to get a transaction id
   * @param transaction object with the information necessary to send an envelope to a bridge
   * @return hash id of the transaction
   */
  function getId(Transaction memory transaction) internal pure returns (bytes32) {
    EncodedTransaction memory encodedTransaction = encode(transaction);
    return encodedTransaction.id;
  }

  /**
   * @notice method to get a transaction id
   * @param transaction encoded transaction object
   * @return hash id of the transaction
   */
  function getId(bytes memory transaction) internal pure returns (bytes32) {
    return keccak256(transaction);
  }

  /**
   * @notice method to get the envelope information from the transaction object
   * @param transaction object with the information necessary to send an envelope to a bridge
   * @return object with decoded information of the envelope in the transaction
   */
  function getEnvelope(Transaction memory transaction) internal pure returns (Envelope memory) {
    return EnvelopeUtils.decode(transaction.encodedEnvelope);
  }

  /**
   * @notice method to get the envelope id from the transaction object
   * @param transaction object with the information necessary to send an envelope to a bridge
   * @return hash id of the envelope on a transaction
   */
  function getEnvelopeId(Transaction memory transaction) internal pure returns (bytes32) {
    return EnvelopeUtils.getId(transaction.encodedEnvelope);
  }
}

File 24 of 26 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title Errors library
 * @author BGD Labs
 * @notice Defines the error messages emitted by the different contracts of the Aave CrossChain Infrastructure
 */
library Errors {
  string public constant ETH_TRANSFER_FAILED = '1'; // failed to transfer eth to destination
  string public constant CALLER_IS_NOT_APPROVED_SENDER = '2'; // caller must be an approved message sender
  string public constant ENVELOPE_NOT_PREVIOUSLY_REGISTERED = '3'; // envelope can only be retried if it has been previously registered
  string public constant CURRENT_OR_DESTINATION_CHAIN_ADAPTER_NOT_SET = '4'; // can not enable bridge adapter if the current or destination chain adapter is 0 address
  string public constant CALLER_NOT_APPROVED_BRIDGE = '5'; // caller must be an approved bridge
  string public constant INVALID_VALIDITY_TIMESTAMP = '6'; // new validity timestamp is not correct (< last validity or in the future
  string public constant CALLER_NOT_CCIP_ROUTER = '7'; // caller must be bridge provider contract
  string public constant CCIP_ROUTER_CANT_BE_ADDRESS_0 = '8'; // CCIP bridge adapters needs a CCIP Router
  string public constant RECEIVER_NOT_SET = '9'; // receiver address on destination chain can not be 0
  string public constant DESTINATION_CHAIN_ID_NOT_SUPPORTED = '10'; // destination chain id must be supported by bridge provider
  string public constant NOT_ENOUGH_VALUE_TO_PAY_BRIDGE_FEES = '11'; // cross chain controller does not have enough funds to forward the message
  string public constant REMOTE_NOT_TRUSTED = '12'; // remote address has not been registered as a trusted origin
  string public constant CALLER_NOT_HL_MAILBOX = '13'; // caller must be the HyperLane Mailbox contract
  string public constant NO_BRIDGE_ADAPTERS_FOR_SPECIFIED_CHAIN = '14'; // no bridge adapters are configured for the specified destination chain
  string public constant ONLY_ONE_EMERGENCY_UPDATE_PER_CHAIN = '15'; // only one emergency update is allowed at the time
  string public constant INVALID_REQUIRED_CONFIRMATIONS = '16'; // required confirmations must be less or equal than allowed adapters or bigger or equal than 1
  string public constant DESTINATION_CHAIN_NOT_SAME_AS_CURRENT_CHAIN = '17'; // destination chain must be the same chain as the current chain where contract is deployed
  string public constant INVALID_BRIDGE_ADAPTER = '18'; // a bridge adapter address can not be the 0 address
  string public constant TRANSACTION_NOT_PREVIOUSLY_FORWARDED = '19'; // to retry sending a transaction, it needs to have been previously sent
  string public constant TRANSACTION_RETRY_FAILED = '20'; // transaction retry has failed (no bridge adapters where able to send)
  string public constant BRIDGE_ADAPTERS_SHOULD_BE_UNIQUE = '21'; // can not use the same bridge adapter twice
  string public constant ENVELOPE_NOT_CONFIRMED_OR_DELIVERED = '22'; // to deliver an envelope, this should have been previously confirmed
  string public constant INVALID_BASE_ADAPTER_CROSS_CHAIN_CONTROLLER = '23'; // crossChainController address can not be 0
  string public constant DELEGATE_CALL_FORBIDDEN = '24'; // calling this function during delegatecall is forbidden
  string public constant CALLER_NOT_LZ_ENDPOINT = '25'; // caller must be the LayerZero endpoint contract
  string public constant INVALID_LZ_ENDPOINT = '26'; // LayerZero endpoint can't be 0
  string public constant INVALID_TRUSTED_REMOTE = '27'; // trusted remote endpoint can't be 0
  string public constant INVALID_EMERGENCY_ORACLE = '28'; // emergency oracle can not be 0 because if not, system could not be rescued on emergency
  string public constant NOT_IN_EMERGENCY = '29'; // execution can only happen when in an emergency
  string public constant LINK_TOKEN_CANT_BE_ADDRESS_0 = '30'; // link token address should be set
  string public constant CCIP_MESSAGE_IS_INVALID = '31'; // ccip message is not an accepted message
  string public constant ADAPTER_PAYMENT_SETUP_FAILED = '32'; // adapter payment setup failed
  string public constant CHAIN_ID_MISMATCH = '33'; // the message delivered to/from wrong network
  string public constant CALLER_NOT_OVM = '34'; // the caller must be the optimism ovm contract
  string public constant CALLER_NOT_FX_TUNNEL = '35'; // the caller must be the fx tunnel contract
  string public constant INVALID_SENDER = '36'; // sender can not be address 0
  string public constant CALLER_NOT_GNOSIS_ARBITRARY_MESSAGE_BRIDGE = '37'; // the caller must be the Gnosis AMB contract
  string public constant ZERO_GNOSIS_ARBITRARY_MESSAGE_BRIDGE = '38'; // The passed Gnosis AMB contract is zero
  string public constant CALLER_NOT_ZK_EVM_BRIDGE = '39'; // the caller must be the zk evm bridge
  string public constant INVALID_HL_MAILBOX = '40'; // the Hyperlane mailbox address can not be 0
  string public constant WORMHOLE_RELAYER_CANT_BE_ADDRESS_0 = '41'; // Wormhole relayer can not be address 0
  string public constant CALLER_NOT_WORMHOLE_RELAYER = '42'; // caller must be the Wormhole relayer
}

File 25 of 26 : CrossChainController.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.8;

import {CrossChainController} from '../../CrossChainController.sol';
import {IReinitialize} from './IReinitialize.sol';

/**
 * @title CrossChainControllerUpgradeRev2
 * @author BGD Labs
 * @notice CrossChainController Revision 2. Contract inheriting from CrossChainController with the addition of re initialization method
 * @dev reinitializer is not used on parent CrossChainController, so this contract is needed to be able to initialize CCC with a new implementation
 */
contract CrossChainControllerUpgradeRev2 is CrossChainController, IReinitialize {
  /// @inheritdoc IReinitialize
  function initializeRevision() external reinitializer(2) {}
}

File 26 of 26 : IReinitialize.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title IReinitialize
 * @author BGD Labs
 * @notice interface containing re initialization method
 */
interface IReinitialize {
  /**
   * @notice method called to re initialize the proxy
   */
  function initializeRevision() external;
}

Settings
{
  "remappings": [
    "solidity-utils/=lib/solidity-utils/src/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@aave/core-v3/=lib/aave-address-book/lib/aave-v3-core/",
    "@aave/periphery-v3/=lib/aave-address-book/lib/aave-v3-periphery/",
    "aave-address-book/=lib/aave-address-book/src/",
    "aave-v3-core/=lib/aave-address-book/lib/aave-v3-core/",
    "aave-v3-periphery/=lib/aave-address-book/lib/aave-v3-periphery/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "fx-portal/=lib/fx-portal/contracts/",
    "nitro-contracts/=lib/nitro-contracts/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "hyperlane-monorepo/=lib/hyperlane-monorepo/solidity/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"bridgeAdapter","type":"address"},{"indexed":false,"internalType":"address","name":"destinationBridgeAdapter","type":"address"},{"indexed":true,"internalType":"bool","name":"allowed","type":"bool"}],"name":"BridgeAdapterUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"newConfirmations","type":"uint8"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"ConfirmationsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Rescued","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"envelopeId","type":"bytes32"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"origin","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct Envelope","name":"envelope","type":"tuple"},{"indexed":false,"internalType":"bool","name":"isDelivered","type":"bool"}],"name":"EnvelopeDeliveryAttempted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"envelopeId","type":"bytes32"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"origin","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct Envelope","name":"envelope","type":"tuple"}],"name":"EnvelopeRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldGuardian","type":"address"},{"indexed":false,"internalType":"address","name":"newGuardian","type":"address"}],"name":"GuardianUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NativeTokensRescued","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"invalidTimestamp","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"NewInvalidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bridgeAdapter","type":"address"},{"indexed":true,"internalType":"bool","name":"allowed","type":"bool"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"ReceiverBridgeAdaptersUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"bool","name":"isApproved","type":"bool"}],"name":"SenderUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"envelopeId","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"encodedTransaction","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"bridgeAdapter","type":"address"},{"indexed":false,"internalType":"address","name":"destinationBridgeAdapter","type":"address"},{"indexed":true,"internalType":"bool","name":"adapterSuccessful","type":"bool"},{"indexed":false,"internalType":"bytes","name":"returnData","type":"bytes"}],"name":"TransactionForwardingAttempted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"envelopeId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"originChainId","type":"uint256"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"encodedEnvelope","type":"bytes"}],"indexed":false,"internalType":"struct Transaction","name":"transaction","type":"tuple"},{"indexed":true,"internalType":"address","name":"bridgeAdapter","type":"address"},{"indexed":false,"internalType":"uint8","name":"confirmations","type":"uint8"}],"name":"TransactionReceived","type":"event"},{"inputs":[{"components":[{"internalType":"address","name":"bridgeAdapter","type":"address"},{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"}],"internalType":"struct ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]","name":"bridgeAdaptersInput","type":"tuple[]"}],"name":"allowReceiverBridgeAdapters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"senders","type":"address[]"}],"name":"approveSenders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"origin","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct Envelope","name":"envelope","type":"tuple"}],"name":"deliverEnvelope","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"bridgeAdapter","type":"address"},{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"}],"internalType":"struct ICrossChainForwarder.BridgeAdapterToDisable[]","name":"bridgeAdapters","type":"tuple[]"}],"name":"disableBridgeAdapters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"bridgeAdapter","type":"address"},{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"}],"internalType":"struct ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]","name":"bridgeAdapters","type":"tuple[]"}],"name":"disallowReceiverBridgeAdapters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyEtherTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"currentChainBridgeAdapter","type":"address"},{"internalType":"address","name":"destinationBridgeAdapter","type":"address"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"internalType":"struct ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]","name":"bridgeAdapters","type":"tuple[]"}],"name":"enableBridgeAdapters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"forwardMessage","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getConfigurationByChain","outputs":[{"components":[{"internalType":"uint8","name":"requiredConfirmation","type":"uint8"},{"internalType":"uint120","name":"validityTimestamp","type":"uint120"}],"internalType":"struct ICrossChainReceiver.ReceiverConfiguration","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentEnvelopeNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentTransactionNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"envelopeId","type":"bytes32"}],"name":"getEnvelopeState","outputs":[{"internalType":"enum ICrossChainReceiver.EnvelopeState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"origin","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct Envelope","name":"envelope","type":"tuple"}],"name":"getEnvelopeState","outputs":[{"internalType":"enum ICrossChainReceiver.EnvelopeState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getForwarderBridgeAdaptersByChain","outputs":[{"components":[{"internalType":"address","name":"destinationBridgeAdapter","type":"address"},{"internalType":"address","name":"currentChainBridgeAdapter","type":"address"}],"internalType":"struct ICrossChainForwarder.ChainIdBridgeConfig[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getReceiverBridgeAdaptersByChain","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedChains","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"encodedEnvelope","type":"bytes"}],"internalType":"struct Transaction","name":"transaction","type":"tuple"}],"name":"getTransactionState","outputs":[{"components":[{"internalType":"uint8","name":"confirmations","type":"uint8"},{"internalType":"uint120","name":"firstBridgedAt","type":"uint120"}],"internalType":"struct ICrossChainReceiver.TransactionStateWithoutAdapters","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"getTransactionState","outputs":[{"components":[{"internalType":"uint8","name":"confirmations","type":"uint8"},{"internalType":"uint120","name":"firstBridgedAt","type":"uint120"}],"internalType":"struct ICrossChainReceiver.TransactionStateWithoutAdapters","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"guardian","type":"address"},{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint8","name":"requiredConfirmations","type":"uint8"}],"internalType":"struct ICrossChainReceiver.ConfirmationInput[]","name":"initialRequiredConfirmations","type":"tuple[]"},{"components":[{"internalType":"address","name":"bridgeAdapter","type":"address"},{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"}],"internalType":"struct ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]","name":"receiverBridgeAdaptersToAllow","type":"tuple[]"},{"components":[{"internalType":"address","name":"currentChainBridgeAdapter","type":"address"},{"internalType":"address","name":"destinationBridgeAdapter","type":"address"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"internalType":"struct ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]","name":"forwarderBridgeAdaptersToEnable","type":"tuple[]"},{"internalType":"address[]","name":"sendersToApprove","type":"address[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializeRevision","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"origin","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct Envelope","name":"envelope","type":"tuple"}],"name":"isEnvelopeRegistered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"envelopeId","type":"bytes32"}],"name":"isEnvelopeRegistered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"bridgeAdapter","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"isReceiverBridgeAdapterAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"isSenderApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"isTransactionForwarded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"encodedEnvelope","type":"bytes"}],"internalType":"struct Transaction","name":"transaction","type":"tuple"}],"name":"isTransactionForwarded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"address","name":"bridgeAdapter","type":"address"}],"name":"isTransactionReceivedByAdapter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedTransaction","type":"bytes"},{"internalType":"uint256","name":"originChainId","type":"uint256"}],"name":"receiveCrossChainMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"senders","type":"address[]"}],"name":"removeSenders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"origin","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct Envelope","name":"envelope","type":"tuple"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"retryEnvelope","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedTransaction","type":"bytes"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"address[]","name":"bridgeAdaptersToRetry","type":"address[]"}],"name":"retryTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint8","name":"requiredConfirmations","type":"uint8"}],"internalType":"struct ICrossChainReceiver.ConfirmationInput[]","name":"newConfirmations","type":"tuple[]"}],"name":"updateConfirmations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGuardian","type":"address"}],"name":"updateGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint120","name":"validityTimestamp","type":"uint120"}],"internalType":"struct ICrossChainReceiver.ValidityTimestampInput[]","name":"newValidityTimestamp","type":"tuple[]"}],"name":"updateMessagesValidityTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"whoCanRescue","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b50604080516000808252602082019092529062000051565b6040805180820190915260008082526020820152815260200190600190039081620000295790505b50604080516000808252602082019092529062000092565b604080518082019091526000815260606020820152815260200190600190039081620000695790505b506040805160008082526020820190925290620000d8565b6040805160608101825260008082526020808301829052928201528252600019909201910181620000aa5790505b50604080516000815260208101909152620000f333620001c1565b620000fe3362000211565b604080516000808252602082019092526200015d9184919062000145565b6040805180820190915260008152606060208201528152602001906001900390816200011c5790505b50604080516000815260208101909152849062000272565b505060408051600080825260208201909252620001ae91839190620001a6565b6040805180820190915260008152606060208201528152602001906001900390816200017d5790505b5084620002a8565b50620001bb9050620002d2565b620011f6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad909910160405180910390a15050565b6200027d8462000395565b620002888362000637565b6200029582600162000927565b620002a281600062000927565b50505050565b620002b583600162000a67565b620002c282600062000a67565b620002cd8162000d07565b505050565b607154610100900460ff1615620003405760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b60648201526084015b60405180910390fd5b60715460ff908116101562000393576071805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b60005b815181101562000633576000828281518110620003b957620003b962001109565b6020026020010151905060006001600160a01b031681602001516001600160a01b031614158015620003f4575080516001600160a01b031615155b604051806040016040528060018152602001600d60fa1b815250906200042f5760405162461bcd60e51b815260040162000337919062001145565b506040808201516000908152600760205290812090805b82548110156200052257600083828154811062000467576200046762001109565b60009182526020909120865160029092020160018101549092506001600160a01b039182169116036200050c57602085015181546001600160a01b03908116911614620005015760208581015182546001600160a01b0319166001600160a01b03918216908117845587516040808a01519051928352600194919093169291600080516020620053cf833981519152910160405180910390a45b600192505062000522565b5080620005198162001190565b91505062000446565b50806200061a5782516040805160048152602481018252602080820180516001600160e01b039081166352d1043d60e01b1790915283518085019094526002845261199960f11b918401919091526200057e93929062000e2116565b50604080518082018252602085810180516001600160a01b03908116845287518116838501908152875460018082018a5560008a81528690209651600290920290960180549184166001600160a01b0319928316178155915191860180549284169290911691909117905587518886015192519551958216865293949316929091600080516020620053cf833981519152910160405180910390a45b50505080806200062a9062001190565b91505062000398565b5050565b60005b8151811015620006335760005b8282815181106200065c576200065c62001109565b6020026020010151602001515181101562000911576000600760008585815181106200068c576200068c62001109565b6020026020010151602001518481518110620006ac57620006ac62001109565b60200260200101518152602001908152602001600020905060005b8154811015620008f957848481518110620006e657620006e662001109565b6020026020010151600001516001600160a01b031682828154811062000710576200071062001109565b60009182526020909120600160029092020101546001600160a01b031603620008e45760008282815481106200074a576200074a62001109565b600091825260209091206002909102015483546001600160a01b03909116915083906200077a90600190620011ac565b815481106200078d576200078d62001109565b9060005260206000209060020201838381548110620007b057620007b062001109565b60009182526020909120825460029092020180546001600160a01b039283166001600160a01b031991821617825560019384015493909101805493909216921691909117905582548390806200080a576200080a620011c2565b60008281526020812060026000199093019283020180546001600160a01b03199081168255600191909101805490911690559155865187908790811062000855576200085562001109565b6020026020010151600001516001600160a01b03168787815181106200087f576200087f62001109565b60200260200101516020015186815181106200089f576200089f62001109565b6020026020010151600080516020620053cf83398151915284604051620008d591906001600160a01b0391909116815260200190565b60405180910390a450620008f9565b80620008f08162001190565b915050620006c7565b50508080620009089062001190565b91505062000647565b50806200091e8162001190565b9150506200063a565b60005b8251811015620002cd5760006001600160a01b031683828151811062000954576200095462001109565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161199b60f11b81525090620009a35760405162461bcd60e51b815260040162000337919062001145565b508160046000858481518110620009be57620009be62001109565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555081151583828151811062000a155762000a1562001109565b60200260200101516001600160a01b03167f626c27c1d088fd70034e681d579a5efd004c3d47a56d3ee07ad256ac7301433360405160405180910390a38062000a5e8162001190565b9150506200092a565b60005b8251811015620002cd57600083828151811062000a8b5762000a8b62001109565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316141560405180604001604052806002815260200161062760f31b8152509062000aec5760405162461bcd60e51b815260040162000337919062001145565b5060005b81602001515181101562000cef576000841562000b945762000b3d8360200151838151811062000b245762000b2462001109565b6020026020010151603d62000ea060201b90919060201c565b5062000b8c8360000151603a60008660200151868151811062000b645762000b6462001109565b6020026020010151815260200190815260200160002060010162000eb760201b90919060201c565b905062000c73565b62000be28360000151603a60008660200151868151811062000bba5762000bba62001109565b6020026020010151815260200190815260200160002060010162000ece60201b90919060201c565b905080801562000c35575062000c33603a60008560200151858151811062000c0e5762000c0e62001109565b6020026020010151815260200190815260200160002060010162000ee560201b60201c565b155b1562000c735762000c718360200151838151811062000c585762000c5862001109565b6020026020010151603d62000ef060201b90919060201c565b505b801562000cd9578260200151828151811062000c935762000c9362001109565b602002602001015185151584600001516001600160a01b03167f537ae69afd3600f30d8c662539017cc022c73b04db804445c9eaae801c2f4a8360405160405180910390a45b508062000ce68162001190565b91505062000af0565b5050808062000cfe9062001190565b91505062000a6a565b60005b81518110156200063357600082828151811062000d2b5762000d2b62001109565b602002602001015190506000816020015160ff1611801562000d71575080516000908152603a6020526040902062000d669060010162000ee5565b816020015160ff1611155b60405180604001604052806002815260200161189b60f11b8152509062000dad5760405162461bcd60e51b815260040162000337919062001145565b506020818101805183516000908152603a8452604090819020805460ff191660ff9384161790558451925190519116815290917f799ef5c83e710778f5725ab120f43a73d21b1d98f2e1a058801728ace31275fd910160405180910390a2508062000e188162001190565b91505062000d0a565b6060600080856001600160a01b03168560405162000e409190620011d8565b600060405180830381855af49150503d806000811462000e7d576040519150601f19603f3d011682016040523d82523d6000602084013e62000e82565b606091505b50909250905062000e968683838762000efe565b9695505050505050565b600062000eae838362000f86565b90505b92915050565b600062000eae836001600160a01b03841662000f86565b600062000eae836001600160a01b03841662000fd8565b600062000eb1825490565b600062000eae838362000fd8565b6060831562000f7257825160000362000f6a576001600160a01b0385163b62000f6a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162000337565b508162000f7e565b62000f7e8383620010dc565b949350505050565b600081815260018301602052604081205462000fcf5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000eb1565b50600062000eb1565b60008181526001830160205260408120548015620010d157600062000fff600183620011ac565b85549091506000906200101590600190620011ac565b90508181146200108157600086600001828154811062001039576200103962001109565b90600052602060002001549050808760000184815481106200105f576200105f62001109565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080620010955762001095620011c2565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505062000eb1565b600091505062000eb1565b815115620010ed5781518083602001fd5b8060405162461bcd60e51b815260040162000337919062001145565b634e487b7160e01b600052603260045260246000fd5b60005b838110156200113c57818101518382015260200162001122565b50506000910152565b6020815260008251806020840152620011668160408501602087016200111f565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b600060018201620011a557620011a56200117a565b5060010190565b8181038181111562000eb15762000eb16200117a565b634e487b7160e01b600052603160045260246000fd5b60008251620011ec8184602087016200111f565b9190910192915050565b6141c980620012066000396000f3fe60806040526004361061023f5760003560e01c80639d0cb9d41161012e578063e01658d9116100ab578063f2fde38b1161006f578063f2fde38b146107ee578063f597deaa1461080e578063f62b984314610823578063fc52539514610843578063fe46a4131461086357600080fd5b8063e01658d914610759578063e3a95a5a14610779578063ed68595a14610799578063eed88b8d146107b9578063efe4b0ae146107d957600080fd5b8063aa3f85c8116100f2578063aa3f85c81461063f578063c37255f21461067c578063c4bffe2b1461069c578063c71cca16146106be578063db58eaec1461072957600080fd5b80639d0cb9d4146105bf578063a25d3892146105df578063a2711ff4146105ff578063a3d5b2551461061f578063a4757b0f1461053157600080fd5b8063654a812b116101bc57806383fec72c1161018057806383fec72c146105115780638da5cb5b1461053157806390f7af541461054f578063917cbb9b1461056f5780639b6c7efa1461058f57600080fd5b8063654a812b1461040d5780636e74ebe81461042c578063715018a6146104925780637670d1d8146104a757806376e5379a146104c757600080fd5b80633eb59f60116102035780633eb59f6014610339578063436bd10314610359578063452a93201461037957806355c4fed4146103ab5780635b9d97c6146103e057600080fd5b80630a234b151461024b5780630fb9ca411461026d5780631947051e146102a357806334f7870c146102c35780633805e84e146102f057600080fd5b3661024657005b600080fd5b34801561025757600080fd5b5061026b61026636600461332f565b610883565b005b34801561027957600080fd5b5061028d6102883660046133db565b610897565b60405161029a9190613451565b60405180910390f35b3480156102af57600080fd5b5061026b6102be366004613501565b6108bd565b3480156102cf57600080fd5b506102e36102de366004613535565b610a01565b60405161029a919061354e565b3480156102fc57600080fd5b5061032961030b3660046135aa565b6001600160a01b031660009081526004602052604090205460ff1690565b604051901515815260200161029a565b34801561034557600080fd5b5061026b610354366004613636565b610a8c565b34801561036557600080fd5b50610329610374366004613501565b610e4d565b34801561038557600080fd5b506001546001600160a01b03165b6040516001600160a01b03909116815260200161029a565b3480156103b757600080fd5b506103cb6103c63660046136a2565b610e5b565b6040805192835260208301919091520161029a565b3480156103ec57600080fd5b506104006103fb366004613535565b6110b2565b60405161029a9190613704565b34801561041957600080fd5b506003545b60405190815260200161029a565b34801561043857600080fd5b5061028d610447366004613535565b6040805180820190915260008082526020820152506000908152603a602090815260409182902082518084019093525460ff8116835261010090046001600160781b03169082015290565b34801561049e57600080fd5b5061026b6110cf565b3480156104b357600080fd5b5061026b6104c2366004613751565b6110e3565b3480156104d357600080fd5b506103296104e2366004613785565b6000828152603b602090815260408083206001600160a01b038516845260010190915290205460ff1692915050565b34801561051d57600080fd5b5061026b61052c366004613972565b6110f6565b34801561053d57600080fd5b506000546001600160a01b0316610393565b34801561055b57600080fd5b5061026b61056a366004613751565b6111cc565b34801561057b57600080fd5b5061026b61058a366004613a3e565b6111df565b34801561059b57600080fd5b506103296105aa366004613535565b60009081526006602052604090205460ff1690565b3480156105cb57600080fd5b5061026b6105da366004613a86565b6111f0565b3480156105eb57600080fd5b5061041e6105fa366004613aba565b611203565b34801561060b57600080fd5b5061026b61061a366004613afe565b6113b7565b34801561062b57600080fd5b5061026b61063a366004613bbf565b6113c8565b34801561064b57600080fd5b5061066f61065a366004613535565b6000908152603c602052604090205460ff1690565b60405161029a9190613c16565b34801561068857600080fd5b506103296106973660046133db565b61148e565b3480156106a857600080fd5b506106b161149c565b60405161029a9190613c3e565b3480156106ca57600080fd5b5061028d6106d9366004613535565b6040805180820190915260008082526020820152506040805180820182526000838152603b60208181529382205460ff811684529490915282526101009092046001600160781b03169082015290565b34801561073557600080fd5b50610329610744366004613535565b60009081526005602052604090205460ff1690565b34801561076557600080fd5b5061066f610774366004613501565b6114a8565b34801561078557600080fd5b5061026b610794366004613a86565b6114b6565b3480156107a557600080fd5b5061026b6107b4366004613c76565b6114c9565b3480156107c557600080fd5b5061026b6107d4366004613cab565b611899565b3480156107e557600080fd5b5060025461041e565b3480156107fa57600080fd5b5061026b6108093660046135aa565b6119e0565b34801561081a57600080fd5b5061026b611a56565b34801561082f57600080fd5b5061032961083e366004613cab565b611ae6565b34801561084f57600080fd5b5061026b61085e3660046135aa565b611b08565b34801561086f57600080fd5b5061026b61087e366004613cd7565b611b19565b61088b611b2a565b61089481611b84565b50565b60408051808201909152600080825260208201526108b76106d983611e28565b92915050565b60006108c882611e3f565b905060016000828152603c602052604090205460ff1660028111156108ef576108ef613c00565b1460405180604001604052806002815260200161191960f11b815250906109325760405162461bcd60e51b81526004016109299190613d5b565b60405180910390fd5b506000818152603c6020908152604091829020805460ff191660021790558382015190840151606085015160a08601519351630a81a65d60e11b81526001600160a01b03909316936315034cba9361098f93929190600401613d6e565b600060405180830381600087803b1580156109a957600080fd5b505af11580156109bd573d6000803e3d6000fd5b505050507fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab818360016040516109f593929190613df3565b60405180910390a15050565b606060076000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a81576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610a36565b505050509050919050565b610a94611e4b565b8251602084012060009060008181526006602052604090205490915060ff1660405180604001604052806002815260200161313960f01b81525090610aec5760405162461bcd60e51b81526004016109299190613d5b565b506000610af885611eba565b90506000610b0582611ee3565b905060006007600083608001518152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610b8b576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610b40565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b81525090610bcf5760405162461bcd60e51b81526004016109299190613d5b565b50600085516001600160401b03811115610beb57610beb61318a565b604051908082528060200260200182016040528015610c3057816020015b6040805180820190915260008082526020820152815260200190600190039081610c095790505b50905060005b8651811015610de8576000610c4c826001613e34565b90505b8751811015610cec57878181518110610c6a57610c6a613e47565b60200260200101516001600160a01b0316888381518110610c8d57610c8d613e47565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161323160f01b81525090610cd95760405162461bcd60e51b81526004016109299190613d5b565b5080610ce481613e5d565b915050610c4f565b506000805b8451811015610d9b57848181518110610d0c57610d0c613e47565b6020026020010151602001516001600160a01b0316898481518110610d3357610d33613e47565b60200260200101516001600160a01b031603610d8957848181518110610d5b57610d5b613e47565b6020026020010151848481518110610d7557610d75613e47565b602002602001018190525060019150610d9b565b80610d9381613e5d565b915050610cf1565b50604080518082019091526002815261062760f31b602082015281610dd35760405162461bcd60e51b81526004016109299190613d5b565b50508080610de090613e5d565b915050610c36565b506000610e05610df786611ef8565b878b87608001518c87611f0b565b90508060405180604001604052806002815260200161032360f41b81525090610e415760405162461bcd60e51b81526004016109299190613d5b565b50505050505050505050565b60006108b761074483611e3f565b33600090815260046020526040812054819060ff16604051806040016040528060018152602001601960f91b81525090610ea85760405162461bcd60e51b81526004016109299190613d5b565b50600086815260076020908152604080832080548251818502810185019093528083529192909190849084015b82821015610f20576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610ed5565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b81525090610f645760405162461bcd60e51b81526004016109299190613d5b565b506002805460009182610f7683613e5d565b91905055905060006040518060c00160405280838152602001336001600160a01b03168152602001896001600160a01b031681526020014681526020018a81526020018781525090506000610fca826120b5565b6020808201805160009081526005909252604091829020805460ff19166001179055519051919250907f18d245f6501b267c6fc4ab6bb6f037c83d28a9ab089e79ab063162d414d2d9c990611020908590613e76565b60405180910390a2600061105e60405180604001604052806003600081548092919061104b90613e5d565b9091555081528451602090910152612116565b6020808201805160009081526006835260409020805460ff1916600117905590840151905182516080870151939450611098938d8a611f0b565b50602091820151910151909a909950975050505050505050565b6000818152603a602052604090206060906108b790600101612151565b6110d7611b2a565b6110e1600061215e565b565b6110eb611b2a565b6108948160006121ae565b607154610100900460ff16158080156111165750607154600160ff909116105b806111305750303b158015611130575060715460ff166001145b61114c5760405162461bcd60e51b815260040161092990613e89565b6071805460ff19166001179055801561116f576071805461ff0019166101001790555b61117d8787878787876122de565b80156111c3576071805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6111d4611b2a565b6108948160016121ae565b6111e7611b2a565b6108948161240f565b6111f8611b2a565b6108948160016126db565b600061120d611e4b565b6000611218846120b5565b9050611237816020015160009081526005602052604090205460ff1690565b604051806040016040528060018152602001603360f81b8152509061126f5760405162461bcd60e51b81526004016109299190613d5b565b5060006007600086608001518152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156112f4576000848152602090819020604080518082019091526002850290910180546001600160a01b039081168352600191820154168284015290835290920191016112a9565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b815250906113385760405162461bcd60e51b81526004016109299190613d5b565b50600061136f60405180604001604052806003600081548092919061135c90613e5d565b9091555081528551602090910152612116565b6020808201805160009081526006835260409020805460ff19166001179055908501519051825160808a01519394506113a9938987611f0b565b506020015195945050505050565b6113bf611b2a565b61089481612946565b6000546001600160a01b031633146114195760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b6044820152606401610929565b61142d6001600160a01b0384168383612a6f565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fc7af665d489507e14ae25ac7ab0030fc7f570869610bdd32117ea56b60ae5c618460405161147c91815260200190565b60405180910390a4505050565b905090565b60006108b76105aa83611e28565b6060611489603d612151565b60006108b761065a83611e3f565b6114be611b2a565b6108948160006126db565b806114d43382611ae6565b604051806040016040528060018152602001603560f81b8152509061150c5760405162461bcd60e51b81526004016109299190613d5b565b50600061151884611eba565b9050600061152582611ee3565b905083816060015114801561153d5750468160800151145b60405180604001604052806002815260200161333360f01b815250906115765760405162461bcd60e51b81526004016109299190613d5b565b50600061158283611ef8565b865160208801209091506000906000818152603b602090815260408083208a8452603a83529281902081518083019092525460ff811682526001600160781b036101009182900481169383019390935283549495509293909290041680158061161d575033600090815260018401602052604090205460ff1615801561161d575081602001516001600160781b0316816001600160781b0316115b15610e4157806001600160781b0316600003611652578254610100600160801b031916610100426001600160781b0316021783555b8254600090849082906116679060ff16613ed7565b825460ff8083166101009490940a93840293021916919091179091553360008181526001878101602052604091829020805460ff1916909117905551919250908b9088907f5353716bf921d1d85f5567a99a718cc63ff1182dca5f9163d9e9b8f1fc3ac387906116dc908a908e908890613f15565b60405180910390a46000868152603c602052604081205460ff16600281111561170757611707613c00565b14611719575050505050505050505050565b825160ff16158015906117365750826000015160ff168160ff1610155b1561188b576000868152603c6020908152604091829020805460ff19166002179055888201519089015160608a015160a08b01519351630a81a65d60e11b81526001600160a01b03909316936315034cba9361179793929190600401613d6e565b600060405180830381600087803b1580156117b157600080fd5b505af19250505080156117c2575060015b61184e573d8080156117f0576040519150601f19603f3d011682016040523d82523d6000602084013e6117f5565b606091505b506000878152603c6020526040808220805460ff19166001179055517fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab91611840918a918c91613df3565b60405180910390a15061188b565b7fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab8688600160405161188293929190613df3565b60405180910390a15b50505050505050505b505050565b6000546001600160a01b031633146118ea5760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b6044820152606401610929565b604080516000808252602082019092526001600160a01b0384169083906040516119149190613f41565b60006040518083038185875af1925050503d8060008114611951576040519150601f19603f3d011682016040523d82523d6000602084013e611956565b606091505b505090508061199b5760405162461bcd60e51b815260206004820152601160248201527011551217d514905394d1915497d1905253607a1b6044820152606401610929565b6040518281526001600160a01b0384169033907fb7c602059992183c7b767c08204223afc99f1895fd175adf9ece23ce9f5bb8b79060200160405180910390a3505050565b6119e8611b2a565b6001600160a01b038116611a4d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610929565b6108948161215e565b607154600290610100900460ff16158015611a78575060715460ff8083169116105b611a945760405162461bcd60e51b815260040161092990613e89565b6071805461ffff191660ff83169081176101001761ff0019169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b6000818152603a60205260408120611b019060010184612ac1565b9392505050565b611b10611e4b565b61089481612ae3565b611b21611b2a565b61089481612b3d565b6000546001600160a01b031633146110e15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610929565b60005b8151811015611e24576000828281518110611ba457611ba4613e47565b6020026020010151905060006001600160a01b031681602001516001600160a01b031614158015611bde575080516001600160a01b031615155b604051806040016040528060018152602001600d60fa1b81525090611c165760405162461bcd60e51b81526004016109299190613d5b565b506040808201516000908152600760205290812090805b8254811015611d10576000838281548110611c4a57611c4a613e47565b60009182526020909120865160029092020160018101549092506001600160a01b03918216911603611cfd57602085015181546001600160a01b03908116911614611cf35760208581015182546001600160a01b0319166001600160a01b03918216908117845587516040808a015190519283526001949190931692917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b6001925050611d10565b5080611d0881613e5d565b915050611c2d565b5080611e0e5782516040805160048152602481018252602080820180516001600160e01b03166352d1043d60e01b17905282518084019093526002835261199960f11b90830152611d619291612c4a565b50604080518082018252602085810180516001600160a01b03908116845287518116838501908152875460018082018a5560008a81528690209651600290920290960180549184166001600160a01b03199283161781559151918601805492841692909116919091179055875188860151925195519582168652939493169290917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b5050508080611e1c90613e5d565b915050611b87565b5050565b600080611e3483612116565b602001519392505050565b600080611e34836120b5565b6000546001600160a01b0316331480611e6e57506001546001600160a01b031633145b6110e15760405162461bcd60e51b815260206004820152601960248201527f4f4e4c595f42595f4f574e45525f4f525f475541524449414e000000000000006044820152606401610929565b604080518082019091526000815260606020820152818060200190518101906108b79190613fa2565b611eeb613142565b6108b78260200151612cc2565b60208082015180519101206000906108b7565b600080805b83518110156120a957600080858381518110611f2e57611f2e613e47565b6020026020010151602001516001600160a01b03166336da7a0660e01b878581518110611f5d57611f5d613e47565b602002602001015160000151898b8d604051602401611f7f9493929190614009565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611fbd9190613f41565b600060405180830381855af49150503d8060008114611ff8576040519150601f19603f3d011682016040523d82523d6000602084013e611ffd565b606091505b5091509150811561200d57600193505b81151586848151811061202257612022613e47565b6020026020010151602001516001600160a01b03168c7f935aa87d643578e6395c90fdbd5d50ffee5f2c1f6ce2cd01274740412bb679f48d8d8d8c8a8151811061206e5761206e613e47565b6020026020010151600001518860405161208c959493929190614036565b60405180910390a4505080806120a190613e5d565b915050611f10565b50979650505050505050565b604080518082019091526060815260006020820152604080518082019091526060815260006020820152826040516020016120f09190613e76565b60408051808303601f190181529190528082528051602090910120602082015292915050565b604080518082019091526060815260006020820152604080518082019091526060815260006020820152826040516020016120f09190614083565b60606000611b0183612cde565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005b82518110156118945760006001600160a01b03168382815181106121d7576121d7613e47565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161199b60f11b815250906122235760405162461bcd60e51b81526004016109299190613d5b565b50816004600085848151811061223b5761223b613e47565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555081151583828151811061228f5761228f613e47565b60200260200101516001600160a01b03167f626c27c1d088fd70034e681d579a5efd004c3d47a56d3ee07ad256ac7301433360405160405180910390a3806122d681613e5d565b9150506121b1565b607154610100900460ff16158080156122fe5750607154600160ff909116105b806123185750303b158015612318575060715460ff166001145b6123345760405162461bcd60e51b815260040161092990613e89565b6071805460ff191660011790558015612357576071805461ff0019166101001790555b6123608761215e565b61236986612ae3565b604080516000808252602082019092526123b4918691906123ad565b6040805180820190915260008152606060208201528152602001906001900390816123855790505b5087612d3a565b6040805160008082526020820190925261117d918591906123f8565b6040805180820190915260008152606060208201528152602001906001900390816123d05790505b506040805160008152602081019091528590612d59565b60005b8151811015611e245760005b82828151811061243057612430613e47565b602002602001015160200151518110156126c85760006007600085858151811061245c5761245c613e47565b602002602001015160200151848151811061247957612479613e47565b60200260200101518152602001908152602001600020905060005b81548110156126b3578484815181106124af576124af613e47565b6020026020010151600001516001600160a01b03168282815481106124d6576124d6613e47565b60009182526020909120600160029092020101546001600160a01b0316036126a157600082828154811061250c5761250c613e47565b600091825260209091206002909102015483546001600160a01b039091169150839061253a90600190614096565b8154811061254a5761254a613e47565b906000526020600020906002020183838154811061256a5761256a613e47565b60009182526020909120825460029092020180546001600160a01b039283166001600160a01b031991821617825560019384015493909101805493909216921691909117905582548390806125c1576125c16140a9565b60008281526020812060026000199093019283020180546001600160a01b03199081168255600191909101805490911690559155865187908790811061260957612609613e47565b6020026020010151600001516001600160a01b031687878151811061263057612630613e47565b602002602001015160200151868151811061264d5761264d613e47565b60200260200101517f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d8460405161269391906001600160a01b0391909116815260200190565b60405180910390a4506126b3565b806126ab81613e5d565b915050612494565b505080806126c090613e5d565b91505061241e565b50806126d381613e5d565b915050612412565b60005b82518110156118945760008382815181106126fb576126fb613e47565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316141560405180604001604052806002815260200161062760f31b815250906127595760405162461bcd60e51b81526004016109299190613d5b565b5060005b81602001515181101561293157600084156127f4576127a38360200151838151811061278b5761278b613e47565b6020026020010151603d612d8790919063ffffffff16565b506127ed8360000151603a6000866020015186815181106127c6576127c6613e47565b60200260200101518152602001908152602001600020600101612d9390919063ffffffff16565b90506128bc565b61283d8360000151603a60008660200151868151811061281657612816613e47565b60200260200101518152602001908152602001600020600101612da890919063ffffffff16565b90508080156128845750612882603a60008560200151858151811061286457612864613e47565b60200260200101518152602001908152602001600020600101612dbd565b155b156128bc576128ba836020015183815181106128a2576128a2613e47565b6020026020010151603d612dc790919063ffffffff16565b505b801561291e57826020015182815181106128d8576128d8613e47565b602002602001015185151584600001516001600160a01b03167f537ae69afd3600f30d8c662539017cc022c73b04db804445c9eaae801c2f4a8360405160405180910390a45b508061292981613e5d565b91505061275d565b5050808061293e90613e5d565b9150506126de565b60005b8151811015611e2457600082828151811061296657612966613e47565b60209081029190910181015180516000908152603a83526040902054918101519092506001600160781b03610100909204821691161180156129b557504281602001516001600160781b031611155b604051806040016040528060018152602001601b60f91b815250906129ed5760405162461bcd60e51b81526004016109299190613d5b565b506020818101805183516000908152603a84526040908190208054610100600160801b0319166101006001600160781b03948516021790558451925190519116815290917f79b1ca301c237cd649b2d35eb6f0873650079b8bb613a17279bbf80332754ddd910160405180910390a25080612a6781613e5d565b915050612949565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611894908490612dd3565b6001600160a01b03811660009081526001830160205260408120541515611b01565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad90991016109f5565b60005b8151811015611e24576000828281518110612b5d57612b5d613e47565b602002602001015190506000816020015160ff16118015612ba0575080516000908152603a60205260409020612b9590600101612dbd565b816020015160ff1611155b60405180604001604052806002815260200161189b60f11b81525090612bd95760405162461bcd60e51b81526004016109299190613d5b565b506020818101805183516000908152603a8452604090819020805460ff191660ff9384161790558451925190519116815290917f799ef5c83e710778f5725ab120f43a73d21b1d98f2e1a058801728ace31275fd910160405180910390a25080612c4281613e5d565b915050612b40565b6060600080856001600160a01b031685604051612c679190613f41565b600060405180830381855af49150503d8060008114612ca2576040519150601f19603f3d011682016040523d82523d6000602084013e612ca7565b606091505b5091509150612cb886838387612e36565b9695505050505050565b612cca613142565b818060200190518101906108b791906140bf565b606081600001805480602002602001604051908101604052809291908181526020018280548015612d2e57602002820191906000526020600020905b815481526020019060010190808311612d1a575b50505050509050919050565b612d458360016126db565b612d508260006126db565b61189481612b3d565b612d6284611b84565b612d6b8361240f565b612d768260016121ae565b612d818160006121ae565b50505050565b6000611b018383612eb7565b6000611b01836001600160a01b038416612eb7565b6000611b01836001600160a01b038416612f06565b60006108b7825490565b6000611b018383612f06565b6000612de86001600160a01b03841683612ff9565b90508051600014158015612e0d575080806020019051810190612e0b9190614171565b155b1561189457604051635274afe760e01b81526001600160a01b0384166004820152602401610929565b60608315612ea5578251600003612e9e576001600160a01b0385163b612e9e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610929565b5081612eaf565b612eaf838361303d565b949350505050565b6000818152600183016020526040812054612efe575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556108b7565b5060006108b7565b60008181526001830160205260408120548015612fef576000612f2a600183614096565b8554909150600090612f3e90600190614096565b9050818114612fa3576000866000018281548110612f5e57612f5e613e47565b9060005260206000200154905080876000018481548110612f8157612f81613e47565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612fb457612fb46140a9565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506108b7565b60009150506108b7565b6060611b01838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250613067565b81511561304d5781518083602001fd5b8060405162461bcd60e51b81526004016109299190613d5b565b6060824710156130c85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610929565b600080866001600160a01b031685876040516130e49190613f41565b60006040518083038185875af1925050503d8060008114613121576040519150601f19603f3d011682016040523d82523d6000602084013e613126565b606091505b509150915061313787838387612e36565b979650505050505050565b6040518060c001604052806000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156131c2576131c261318a565b60405290565b604080519081016001600160401b03811182821017156131c2576131c261318a565b60405160c081016001600160401b03811182821017156131c2576131c261318a565b604051601f8201601f191681016001600160401b03811182821017156132345761323461318a565b604052919050565b60006001600160401b038211156132555761325561318a565b5060051b60200190565b6001600160a01b038116811461089457600080fd5b803561327f8161325f565b919050565b600082601f83011261329557600080fd5b813560206132aa6132a58361323c565b61320c565b828152606092830285018201928282019190878511156132c957600080fd5b8387015b858110156133225781818a0312156132e55760008081fd5b6132ed6131a0565b81356132f88161325f565b8152818601356133078161325f565b818701526040828101359082015284529284019281016132cd565b5090979650505050505050565b60006020828403121561334157600080fd5b81356001600160401b0381111561335757600080fd5b612eaf84828501613284565b60006001600160401b0382111561337c5761337c61318a565b50601f01601f191660200190565b600082601f83011261339b57600080fd5b81356133a96132a582613363565b8181528460208386010111156133be57600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156133ed57600080fd5b81356001600160401b038082111561340457600080fd5b908301906040828603121561341857600080fd5b6134206131c8565b8235815260208301358281111561343657600080fd5b6134428782860161338a565b60208301525095945050505050565b815160ff1681526020808301516001600160781b031690820152604081016108b7565b600060c0828403121561348657600080fd5b61348e6131ea565b90508135815260208201356134a28161325f565b602082015260408201356134b58161325f565b80604083015250606082013560608201526080820135608082015260a08201356001600160401b038111156134e957600080fd5b6134f58482850161338a565b60a08301525092915050565b60006020828403121561351357600080fd5b81356001600160401b0381111561352957600080fd5b612eaf84828501613474565b60006020828403121561354757600080fd5b5035919050565b602080825282518282018190526000919060409081850190868401855b8281101561359d57815180516001600160a01b039081168652908701511686850152928401929085019060010161356b565b5091979650505050505050565b6000602082840312156135bc57600080fd5b8135611b018161325f565b600082601f8301126135d857600080fd5b813560206135e86132a58361323c565b82815260059290921b8401810191818101908684111561360757600080fd5b8286015b8481101561362b57803561361e8161325f565b835291830191830161360b565b509695505050505050565b60008060006060848603121561364b57600080fd5b83356001600160401b038082111561366257600080fd5b61366e8783880161338a565b945060208601359350604086013591508082111561368b57600080fd5b50613698868287016135c7565b9150509250925092565b600080600080608085870312156136b857600080fd5b8435935060208501356136ca8161325f565b92506040850135915060608501356001600160401b038111156136ec57600080fd5b6136f88782880161338a565b91505092959194509250565b6020808252825182820181905260009190848201906040850190845b818110156137455783516001600160a01b031683529284019291840191600101613720565b50909695505050505050565b60006020828403121561376357600080fd5b81356001600160401b0381111561377957600080fd5b612eaf848285016135c7565b6000806040838503121561379857600080fd5b8235915060208301356137aa8161325f565b809150509250929050565b600082601f8301126137c657600080fd5b813560206137d66132a58361323c565b82815260069290921b840181019181810190868411156137f557600080fd5b8286015b8481101561362b57604081890312156138125760008081fd5b61381a6131c8565b813581528482013560ff811681146138325760008081fd5b818601528352918301916040016137f9565b60006138526132a58461323c565b8381529050602080820190600585811b85018781111561387157600080fd5b855b818110156139465780356001600160401b03808211156138935760008081fd5b908801906040828c0312156138a85760008081fd5b6138b06131c8565b82356138bb8161325f565b815282870135828111156138cf5760008081fd5b8084019350508b601f8401126138e757600091508182fd5b823591506138f76132a58361323c565b82815291861b8301870191878101908d8411156139145760008081fd5b938801935b8385101561393257843582529388019390880190613919565b828901525087525050938301938301613873565b50505050509392505050565b600082601f83011261396357600080fd5b611b0183833560208501613844565b60008060008060008060c0878903121561398b57600080fd5b61399487613274565b95506139a260208801613274565b945060408701356001600160401b03808211156139be57600080fd5b6139ca8a838b016137b5565b955060608901359150808211156139e057600080fd5b6139ec8a838b01613952565b94506080890135915080821115613a0257600080fd5b613a0e8a838b01613284565b935060a0890135915080821115613a2457600080fd5b50613a3189828a016135c7565b9150509295509295509295565b600060208284031215613a5057600080fd5b81356001600160401b03811115613a6657600080fd5b8201601f81018413613a7757600080fd5b612eaf84823560208401613844565b600060208284031215613a9857600080fd5b81356001600160401b03811115613aae57600080fd5b612eaf84828501613952565b60008060408385031215613acd57600080fd5b82356001600160401b03811115613ae357600080fd5b613aef85828601613474565b95602094909401359450505050565b60006020808385031215613b1157600080fd5b82356001600160401b03811115613b2757600080fd5b8301601f81018513613b3857600080fd5b8035613b466132a58261323c565b81815260069190911b82018301908381019087831115613b6557600080fd5b928401925b828410156131375760408489031215613b835760008081fd5b613b8b6131c8565b84358152858501356001600160781b0381168114613ba95760008081fd5b8187015282526040939093019290840190613b6a565b600080600060608486031215613bd457600080fd5b8335613bdf8161325f565b92506020840135613bef8161325f565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b6020810160038310613c3857634e487b7160e01b600052602160045260246000fd5b91905290565b6020808252825182820181905260009190848201906040850190845b8181101561374557835183529284019291840191600101613c5a565b60008060408385031215613c8957600080fd5b82356001600160401b03811115613c9f57600080fd5b613aef8582860161338a565b60008060408385031215613cbe57600080fd5b8235613cc98161325f565b946020939093013593505050565b600060208284031215613ce957600080fd5b81356001600160401b03811115613cff57600080fd5b612eaf848285016137b5565b60005b83811015613d26578181015183820152602001613d0e565b50506000910152565b60008151808452613d47816020860160208601613d0b565b601f01601f19169290920160200192915050565b602081526000611b016020830184613d2f565b60018060a01b0384168152826020820152606060408201526000613d956060830184613d2f565b95945050505050565b805182526000602082015160018060a01b0380821660208601528060408501511660408601525050606082015160608401526080820151608084015260a082015160c060a0850152612eaf60c0850182613d2f565b838152606060208201526000613e0c6060830185613d9e565b90508215156040830152949350505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156108b7576108b7613e1e565b634e487b7160e01b600052603260045260246000fd5b600060018201613e6f57613e6f613e1e565b5060010190565b602081526000611b016020830184613d9e565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b600060ff821660ff8103613eed57613eed613e1e565b60010192915050565b805182526000602082015160406020850152612eaf6040850182613d2f565b838152606060208201526000613f2e6060830185613ef6565b905060ff83166040830152949350505050565b60008251613f53818460208701613d0b565b9190910192915050565b600082601f830112613f6e57600080fd5b8151613f7c6132a582613363565b818152846020838601011115613f9157600080fd5b612eaf826020830160208701613d0b565b600060208284031215613fb457600080fd5b81516001600160401b0380821115613fcb57600080fd5b9083019060408286031215613fdf57600080fd5b613fe76131c8565b82518152602083015182811115613ffd57600080fd5b61344287828601613f5d565b60018060a01b0385168152836020820152826040820152608060608201526000612cb86080830184613d2f565b85815260a06020820152600061404f60a0830187613d2f565b604083018690526001600160a01b038516606084015282810360808401526140778185613d2f565b98975050505050505050565b602081526000611b016020830184613ef6565b818103818111156108b7576108b7613e1e565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156140d157600080fd5b81516001600160401b03808211156140e857600080fd5b9083019060c082860312156140fc57600080fd5b6141046131ea565b8251815260208301516141168161325f565b602082015260408301516141298161325f565b80604083015250606083015160608201526080830151608082015260a08301518281111561415657600080fd5b61416287828601613f5d565b60a08301525095945050505050565b60006020828403121561418357600080fd5b81518015158114611b0157600080fdfea2646970667358221220f254ff44a83cd67c6ee2e70a17a1ccf38432a4a1e66aa3f886952537a74ea17964736f6c634300081300332152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d

Deployed Bytecode

0x60806040526004361061023f5760003560e01c80639d0cb9d41161012e578063e01658d9116100ab578063f2fde38b1161006f578063f2fde38b146107ee578063f597deaa1461080e578063f62b984314610823578063fc52539514610843578063fe46a4131461086357600080fd5b8063e01658d914610759578063e3a95a5a14610779578063ed68595a14610799578063eed88b8d146107b9578063efe4b0ae146107d957600080fd5b8063aa3f85c8116100f2578063aa3f85c81461063f578063c37255f21461067c578063c4bffe2b1461069c578063c71cca16146106be578063db58eaec1461072957600080fd5b80639d0cb9d4146105bf578063a25d3892146105df578063a2711ff4146105ff578063a3d5b2551461061f578063a4757b0f1461053157600080fd5b8063654a812b116101bc57806383fec72c1161018057806383fec72c146105115780638da5cb5b1461053157806390f7af541461054f578063917cbb9b1461056f5780639b6c7efa1461058f57600080fd5b8063654a812b1461040d5780636e74ebe81461042c578063715018a6146104925780637670d1d8146104a757806376e5379a146104c757600080fd5b80633eb59f60116102035780633eb59f6014610339578063436bd10314610359578063452a93201461037957806355c4fed4146103ab5780635b9d97c6146103e057600080fd5b80630a234b151461024b5780630fb9ca411461026d5780631947051e146102a357806334f7870c146102c35780633805e84e146102f057600080fd5b3661024657005b600080fd5b34801561025757600080fd5b5061026b61026636600461332f565b610883565b005b34801561027957600080fd5b5061028d6102883660046133db565b610897565b60405161029a9190613451565b60405180910390f35b3480156102af57600080fd5b5061026b6102be366004613501565b6108bd565b3480156102cf57600080fd5b506102e36102de366004613535565b610a01565b60405161029a919061354e565b3480156102fc57600080fd5b5061032961030b3660046135aa565b6001600160a01b031660009081526004602052604090205460ff1690565b604051901515815260200161029a565b34801561034557600080fd5b5061026b610354366004613636565b610a8c565b34801561036557600080fd5b50610329610374366004613501565b610e4d565b34801561038557600080fd5b506001546001600160a01b03165b6040516001600160a01b03909116815260200161029a565b3480156103b757600080fd5b506103cb6103c63660046136a2565b610e5b565b6040805192835260208301919091520161029a565b3480156103ec57600080fd5b506104006103fb366004613535565b6110b2565b60405161029a9190613704565b34801561041957600080fd5b506003545b60405190815260200161029a565b34801561043857600080fd5b5061028d610447366004613535565b6040805180820190915260008082526020820152506000908152603a602090815260409182902082518084019093525460ff8116835261010090046001600160781b03169082015290565b34801561049e57600080fd5b5061026b6110cf565b3480156104b357600080fd5b5061026b6104c2366004613751565b6110e3565b3480156104d357600080fd5b506103296104e2366004613785565b6000828152603b602090815260408083206001600160a01b038516845260010190915290205460ff1692915050565b34801561051d57600080fd5b5061026b61052c366004613972565b6110f6565b34801561053d57600080fd5b506000546001600160a01b0316610393565b34801561055b57600080fd5b5061026b61056a366004613751565b6111cc565b34801561057b57600080fd5b5061026b61058a366004613a3e565b6111df565b34801561059b57600080fd5b506103296105aa366004613535565b60009081526006602052604090205460ff1690565b3480156105cb57600080fd5b5061026b6105da366004613a86565b6111f0565b3480156105eb57600080fd5b5061041e6105fa366004613aba565b611203565b34801561060b57600080fd5b5061026b61061a366004613afe565b6113b7565b34801561062b57600080fd5b5061026b61063a366004613bbf565b6113c8565b34801561064b57600080fd5b5061066f61065a366004613535565b6000908152603c602052604090205460ff1690565b60405161029a9190613c16565b34801561068857600080fd5b506103296106973660046133db565b61148e565b3480156106a857600080fd5b506106b161149c565b60405161029a9190613c3e565b3480156106ca57600080fd5b5061028d6106d9366004613535565b6040805180820190915260008082526020820152506040805180820182526000838152603b60208181529382205460ff811684529490915282526101009092046001600160781b03169082015290565b34801561073557600080fd5b50610329610744366004613535565b60009081526005602052604090205460ff1690565b34801561076557600080fd5b5061066f610774366004613501565b6114a8565b34801561078557600080fd5b5061026b610794366004613a86565b6114b6565b3480156107a557600080fd5b5061026b6107b4366004613c76565b6114c9565b3480156107c557600080fd5b5061026b6107d4366004613cab565b611899565b3480156107e557600080fd5b5060025461041e565b3480156107fa57600080fd5b5061026b6108093660046135aa565b6119e0565b34801561081a57600080fd5b5061026b611a56565b34801561082f57600080fd5b5061032961083e366004613cab565b611ae6565b34801561084f57600080fd5b5061026b61085e3660046135aa565b611b08565b34801561086f57600080fd5b5061026b61087e366004613cd7565b611b19565b61088b611b2a565b61089481611b84565b50565b60408051808201909152600080825260208201526108b76106d983611e28565b92915050565b60006108c882611e3f565b905060016000828152603c602052604090205460ff1660028111156108ef576108ef613c00565b1460405180604001604052806002815260200161191960f11b815250906109325760405162461bcd60e51b81526004016109299190613d5b565b60405180910390fd5b506000818152603c6020908152604091829020805460ff191660021790558382015190840151606085015160a08601519351630a81a65d60e11b81526001600160a01b03909316936315034cba9361098f93929190600401613d6e565b600060405180830381600087803b1580156109a957600080fd5b505af11580156109bd573d6000803e3d6000fd5b505050507fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab818360016040516109f593929190613df3565b60405180910390a15050565b606060076000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a81576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610a36565b505050509050919050565b610a94611e4b565b8251602084012060009060008181526006602052604090205490915060ff1660405180604001604052806002815260200161313960f01b81525090610aec5760405162461bcd60e51b81526004016109299190613d5b565b506000610af885611eba565b90506000610b0582611ee3565b905060006007600083608001518152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610b8b576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610b40565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b81525090610bcf5760405162461bcd60e51b81526004016109299190613d5b565b50600085516001600160401b03811115610beb57610beb61318a565b604051908082528060200260200182016040528015610c3057816020015b6040805180820190915260008082526020820152815260200190600190039081610c095790505b50905060005b8651811015610de8576000610c4c826001613e34565b90505b8751811015610cec57878181518110610c6a57610c6a613e47565b60200260200101516001600160a01b0316888381518110610c8d57610c8d613e47565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161323160f01b81525090610cd95760405162461bcd60e51b81526004016109299190613d5b565b5080610ce481613e5d565b915050610c4f565b506000805b8451811015610d9b57848181518110610d0c57610d0c613e47565b6020026020010151602001516001600160a01b0316898481518110610d3357610d33613e47565b60200260200101516001600160a01b031603610d8957848181518110610d5b57610d5b613e47565b6020026020010151848481518110610d7557610d75613e47565b602002602001018190525060019150610d9b565b80610d9381613e5d565b915050610cf1565b50604080518082019091526002815261062760f31b602082015281610dd35760405162461bcd60e51b81526004016109299190613d5b565b50508080610de090613e5d565b915050610c36565b506000610e05610df786611ef8565b878b87608001518c87611f0b565b90508060405180604001604052806002815260200161032360f41b81525090610e415760405162461bcd60e51b81526004016109299190613d5b565b50505050505050505050565b60006108b761074483611e3f565b33600090815260046020526040812054819060ff16604051806040016040528060018152602001601960f91b81525090610ea85760405162461bcd60e51b81526004016109299190613d5b565b50600086815260076020908152604080832080548251818502810185019093528083529192909190849084015b82821015610f20576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610ed5565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b81525090610f645760405162461bcd60e51b81526004016109299190613d5b565b506002805460009182610f7683613e5d565b91905055905060006040518060c00160405280838152602001336001600160a01b03168152602001896001600160a01b031681526020014681526020018a81526020018781525090506000610fca826120b5565b6020808201805160009081526005909252604091829020805460ff19166001179055519051919250907f18d245f6501b267c6fc4ab6bb6f037c83d28a9ab089e79ab063162d414d2d9c990611020908590613e76565b60405180910390a2600061105e60405180604001604052806003600081548092919061104b90613e5d565b9091555081528451602090910152612116565b6020808201805160009081526006835260409020805460ff1916600117905590840151905182516080870151939450611098938d8a611f0b565b50602091820151910151909a909950975050505050505050565b6000818152603a602052604090206060906108b790600101612151565b6110d7611b2a565b6110e1600061215e565b565b6110eb611b2a565b6108948160006121ae565b607154610100900460ff16158080156111165750607154600160ff909116105b806111305750303b158015611130575060715460ff166001145b61114c5760405162461bcd60e51b815260040161092990613e89565b6071805460ff19166001179055801561116f576071805461ff0019166101001790555b61117d8787878787876122de565b80156111c3576071805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6111d4611b2a565b6108948160016121ae565b6111e7611b2a565b6108948161240f565b6111f8611b2a565b6108948160016126db565b600061120d611e4b565b6000611218846120b5565b9050611237816020015160009081526005602052604090205460ff1690565b604051806040016040528060018152602001603360f81b8152509061126f5760405162461bcd60e51b81526004016109299190613d5b565b5060006007600086608001518152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156112f4576000848152602090819020604080518082019091526002850290910180546001600160a01b039081168352600191820154168284015290835290920191016112a9565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b815250906113385760405162461bcd60e51b81526004016109299190613d5b565b50600061136f60405180604001604052806003600081548092919061135c90613e5d565b9091555081528551602090910152612116565b6020808201805160009081526006835260409020805460ff19166001179055908501519051825160808a01519394506113a9938987611f0b565b506020015195945050505050565b6113bf611b2a565b61089481612946565b6000546001600160a01b031633146114195760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b6044820152606401610929565b61142d6001600160a01b0384168383612a6f565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fc7af665d489507e14ae25ac7ab0030fc7f570869610bdd32117ea56b60ae5c618460405161147c91815260200190565b60405180910390a4505050565b905090565b60006108b76105aa83611e28565b6060611489603d612151565b60006108b761065a83611e3f565b6114be611b2a565b6108948160006126db565b806114d43382611ae6565b604051806040016040528060018152602001603560f81b8152509061150c5760405162461bcd60e51b81526004016109299190613d5b565b50600061151884611eba565b9050600061152582611ee3565b905083816060015114801561153d5750468160800151145b60405180604001604052806002815260200161333360f01b815250906115765760405162461bcd60e51b81526004016109299190613d5b565b50600061158283611ef8565b865160208801209091506000906000818152603b602090815260408083208a8452603a83529281902081518083019092525460ff811682526001600160781b036101009182900481169383019390935283549495509293909290041680158061161d575033600090815260018401602052604090205460ff1615801561161d575081602001516001600160781b0316816001600160781b0316115b15610e4157806001600160781b0316600003611652578254610100600160801b031916610100426001600160781b0316021783555b8254600090849082906116679060ff16613ed7565b825460ff8083166101009490940a93840293021916919091179091553360008181526001878101602052604091829020805460ff1916909117905551919250908b9088907f5353716bf921d1d85f5567a99a718cc63ff1182dca5f9163d9e9b8f1fc3ac387906116dc908a908e908890613f15565b60405180910390a46000868152603c602052604081205460ff16600281111561170757611707613c00565b14611719575050505050505050505050565b825160ff16158015906117365750826000015160ff168160ff1610155b1561188b576000868152603c6020908152604091829020805460ff19166002179055888201519089015160608a015160a08b01519351630a81a65d60e11b81526001600160a01b03909316936315034cba9361179793929190600401613d6e565b600060405180830381600087803b1580156117b157600080fd5b505af19250505080156117c2575060015b61184e573d8080156117f0576040519150601f19603f3d011682016040523d82523d6000602084013e6117f5565b606091505b506000878152603c6020526040808220805460ff19166001179055517fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab91611840918a918c91613df3565b60405180910390a15061188b565b7fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab8688600160405161188293929190613df3565b60405180910390a15b50505050505050505b505050565b6000546001600160a01b031633146118ea5760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b6044820152606401610929565b604080516000808252602082019092526001600160a01b0384169083906040516119149190613f41565b60006040518083038185875af1925050503d8060008114611951576040519150601f19603f3d011682016040523d82523d6000602084013e611956565b606091505b505090508061199b5760405162461bcd60e51b815260206004820152601160248201527011551217d514905394d1915497d1905253607a1b6044820152606401610929565b6040518281526001600160a01b0384169033907fb7c602059992183c7b767c08204223afc99f1895fd175adf9ece23ce9f5bb8b79060200160405180910390a3505050565b6119e8611b2a565b6001600160a01b038116611a4d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610929565b6108948161215e565b607154600290610100900460ff16158015611a78575060715460ff8083169116105b611a945760405162461bcd60e51b815260040161092990613e89565b6071805461ffff191660ff83169081176101001761ff0019169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b6000818152603a60205260408120611b019060010184612ac1565b9392505050565b611b10611e4b565b61089481612ae3565b611b21611b2a565b61089481612b3d565b6000546001600160a01b031633146110e15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610929565b60005b8151811015611e24576000828281518110611ba457611ba4613e47565b6020026020010151905060006001600160a01b031681602001516001600160a01b031614158015611bde575080516001600160a01b031615155b604051806040016040528060018152602001600d60fa1b81525090611c165760405162461bcd60e51b81526004016109299190613d5b565b506040808201516000908152600760205290812090805b8254811015611d10576000838281548110611c4a57611c4a613e47565b60009182526020909120865160029092020160018101549092506001600160a01b03918216911603611cfd57602085015181546001600160a01b03908116911614611cf35760208581015182546001600160a01b0319166001600160a01b03918216908117845587516040808a015190519283526001949190931692917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b6001925050611d10565b5080611d0881613e5d565b915050611c2d565b5080611e0e5782516040805160048152602481018252602080820180516001600160e01b03166352d1043d60e01b17905282518084019093526002835261199960f11b90830152611d619291612c4a565b50604080518082018252602085810180516001600160a01b03908116845287518116838501908152875460018082018a5560008a81528690209651600290920290960180549184166001600160a01b03199283161781559151918601805492841692909116919091179055875188860151925195519582168652939493169290917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b5050508080611e1c90613e5d565b915050611b87565b5050565b600080611e3483612116565b602001519392505050565b600080611e34836120b5565b6000546001600160a01b0316331480611e6e57506001546001600160a01b031633145b6110e15760405162461bcd60e51b815260206004820152601960248201527f4f4e4c595f42595f4f574e45525f4f525f475541524449414e000000000000006044820152606401610929565b604080518082019091526000815260606020820152818060200190518101906108b79190613fa2565b611eeb613142565b6108b78260200151612cc2565b60208082015180519101206000906108b7565b600080805b83518110156120a957600080858381518110611f2e57611f2e613e47565b6020026020010151602001516001600160a01b03166336da7a0660e01b878581518110611f5d57611f5d613e47565b602002602001015160000151898b8d604051602401611f7f9493929190614009565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611fbd9190613f41565b600060405180830381855af49150503d8060008114611ff8576040519150601f19603f3d011682016040523d82523d6000602084013e611ffd565b606091505b5091509150811561200d57600193505b81151586848151811061202257612022613e47565b6020026020010151602001516001600160a01b03168c7f935aa87d643578e6395c90fdbd5d50ffee5f2c1f6ce2cd01274740412bb679f48d8d8d8c8a8151811061206e5761206e613e47565b6020026020010151600001518860405161208c959493929190614036565b60405180910390a4505080806120a190613e5d565b915050611f10565b50979650505050505050565b604080518082019091526060815260006020820152604080518082019091526060815260006020820152826040516020016120f09190613e76565b60408051808303601f190181529190528082528051602090910120602082015292915050565b604080518082019091526060815260006020820152604080518082019091526060815260006020820152826040516020016120f09190614083565b60606000611b0183612cde565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005b82518110156118945760006001600160a01b03168382815181106121d7576121d7613e47565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161199b60f11b815250906122235760405162461bcd60e51b81526004016109299190613d5b565b50816004600085848151811061223b5761223b613e47565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555081151583828151811061228f5761228f613e47565b60200260200101516001600160a01b03167f626c27c1d088fd70034e681d579a5efd004c3d47a56d3ee07ad256ac7301433360405160405180910390a3806122d681613e5d565b9150506121b1565b607154610100900460ff16158080156122fe5750607154600160ff909116105b806123185750303b158015612318575060715460ff166001145b6123345760405162461bcd60e51b815260040161092990613e89565b6071805460ff191660011790558015612357576071805461ff0019166101001790555b6123608761215e565b61236986612ae3565b604080516000808252602082019092526123b4918691906123ad565b6040805180820190915260008152606060208201528152602001906001900390816123855790505b5087612d3a565b6040805160008082526020820190925261117d918591906123f8565b6040805180820190915260008152606060208201528152602001906001900390816123d05790505b506040805160008152602081019091528590612d59565b60005b8151811015611e245760005b82828151811061243057612430613e47565b602002602001015160200151518110156126c85760006007600085858151811061245c5761245c613e47565b602002602001015160200151848151811061247957612479613e47565b60200260200101518152602001908152602001600020905060005b81548110156126b3578484815181106124af576124af613e47565b6020026020010151600001516001600160a01b03168282815481106124d6576124d6613e47565b60009182526020909120600160029092020101546001600160a01b0316036126a157600082828154811061250c5761250c613e47565b600091825260209091206002909102015483546001600160a01b039091169150839061253a90600190614096565b8154811061254a5761254a613e47565b906000526020600020906002020183838154811061256a5761256a613e47565b60009182526020909120825460029092020180546001600160a01b039283166001600160a01b031991821617825560019384015493909101805493909216921691909117905582548390806125c1576125c16140a9565b60008281526020812060026000199093019283020180546001600160a01b03199081168255600191909101805490911690559155865187908790811061260957612609613e47565b6020026020010151600001516001600160a01b031687878151811061263057612630613e47565b602002602001015160200151868151811061264d5761264d613e47565b60200260200101517f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d8460405161269391906001600160a01b0391909116815260200190565b60405180910390a4506126b3565b806126ab81613e5d565b915050612494565b505080806126c090613e5d565b91505061241e565b50806126d381613e5d565b915050612412565b60005b82518110156118945760008382815181106126fb576126fb613e47565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316141560405180604001604052806002815260200161062760f31b815250906127595760405162461bcd60e51b81526004016109299190613d5b565b5060005b81602001515181101561293157600084156127f4576127a38360200151838151811061278b5761278b613e47565b6020026020010151603d612d8790919063ffffffff16565b506127ed8360000151603a6000866020015186815181106127c6576127c6613e47565b60200260200101518152602001908152602001600020600101612d9390919063ffffffff16565b90506128bc565b61283d8360000151603a60008660200151868151811061281657612816613e47565b60200260200101518152602001908152602001600020600101612da890919063ffffffff16565b90508080156128845750612882603a60008560200151858151811061286457612864613e47565b60200260200101518152602001908152602001600020600101612dbd565b155b156128bc576128ba836020015183815181106128a2576128a2613e47565b6020026020010151603d612dc790919063ffffffff16565b505b801561291e57826020015182815181106128d8576128d8613e47565b602002602001015185151584600001516001600160a01b03167f537ae69afd3600f30d8c662539017cc022c73b04db804445c9eaae801c2f4a8360405160405180910390a45b508061292981613e5d565b91505061275d565b5050808061293e90613e5d565b9150506126de565b60005b8151811015611e2457600082828151811061296657612966613e47565b60209081029190910181015180516000908152603a83526040902054918101519092506001600160781b03610100909204821691161180156129b557504281602001516001600160781b031611155b604051806040016040528060018152602001601b60f91b815250906129ed5760405162461bcd60e51b81526004016109299190613d5b565b506020818101805183516000908152603a84526040908190208054610100600160801b0319166101006001600160781b03948516021790558451925190519116815290917f79b1ca301c237cd649b2d35eb6f0873650079b8bb613a17279bbf80332754ddd910160405180910390a25080612a6781613e5d565b915050612949565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611894908490612dd3565b6001600160a01b03811660009081526001830160205260408120541515611b01565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad90991016109f5565b60005b8151811015611e24576000828281518110612b5d57612b5d613e47565b602002602001015190506000816020015160ff16118015612ba0575080516000908152603a60205260409020612b9590600101612dbd565b816020015160ff1611155b60405180604001604052806002815260200161189b60f11b81525090612bd95760405162461bcd60e51b81526004016109299190613d5b565b506020818101805183516000908152603a8452604090819020805460ff191660ff9384161790558451925190519116815290917f799ef5c83e710778f5725ab120f43a73d21b1d98f2e1a058801728ace31275fd910160405180910390a25080612c4281613e5d565b915050612b40565b6060600080856001600160a01b031685604051612c679190613f41565b600060405180830381855af49150503d8060008114612ca2576040519150601f19603f3d011682016040523d82523d6000602084013e612ca7565b606091505b5091509150612cb886838387612e36565b9695505050505050565b612cca613142565b818060200190518101906108b791906140bf565b606081600001805480602002602001604051908101604052809291908181526020018280548015612d2e57602002820191906000526020600020905b815481526020019060010190808311612d1a575b50505050509050919050565b612d458360016126db565b612d508260006126db565b61189481612b3d565b612d6284611b84565b612d6b8361240f565b612d768260016121ae565b612d818160006121ae565b50505050565b6000611b018383612eb7565b6000611b01836001600160a01b038416612eb7565b6000611b01836001600160a01b038416612f06565b60006108b7825490565b6000611b018383612f06565b6000612de86001600160a01b03841683612ff9565b90508051600014158015612e0d575080806020019051810190612e0b9190614171565b155b1561189457604051635274afe760e01b81526001600160a01b0384166004820152602401610929565b60608315612ea5578251600003612e9e576001600160a01b0385163b612e9e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610929565b5081612eaf565b612eaf838361303d565b949350505050565b6000818152600183016020526040812054612efe575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556108b7565b5060006108b7565b60008181526001830160205260408120548015612fef576000612f2a600183614096565b8554909150600090612f3e90600190614096565b9050818114612fa3576000866000018281548110612f5e57612f5e613e47565b9060005260206000200154905080876000018481548110612f8157612f81613e47565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612fb457612fb46140a9565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506108b7565b60009150506108b7565b6060611b01838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250613067565b81511561304d5781518083602001fd5b8060405162461bcd60e51b81526004016109299190613d5b565b6060824710156130c85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610929565b600080866001600160a01b031685876040516130e49190613f41565b60006040518083038185875af1925050503d8060008114613121576040519150601f19603f3d011682016040523d82523d6000602084013e613126565b606091505b509150915061313787838387612e36565b979650505050505050565b6040518060c001604052806000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156131c2576131c261318a565b60405290565b604080519081016001600160401b03811182821017156131c2576131c261318a565b60405160c081016001600160401b03811182821017156131c2576131c261318a565b604051601f8201601f191681016001600160401b03811182821017156132345761323461318a565b604052919050565b60006001600160401b038211156132555761325561318a565b5060051b60200190565b6001600160a01b038116811461089457600080fd5b803561327f8161325f565b919050565b600082601f83011261329557600080fd5b813560206132aa6132a58361323c565b61320c565b828152606092830285018201928282019190878511156132c957600080fd5b8387015b858110156133225781818a0312156132e55760008081fd5b6132ed6131a0565b81356132f88161325f565b8152818601356133078161325f565b818701526040828101359082015284529284019281016132cd565b5090979650505050505050565b60006020828403121561334157600080fd5b81356001600160401b0381111561335757600080fd5b612eaf84828501613284565b60006001600160401b0382111561337c5761337c61318a565b50601f01601f191660200190565b600082601f83011261339b57600080fd5b81356133a96132a582613363565b8181528460208386010111156133be57600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156133ed57600080fd5b81356001600160401b038082111561340457600080fd5b908301906040828603121561341857600080fd5b6134206131c8565b8235815260208301358281111561343657600080fd5b6134428782860161338a565b60208301525095945050505050565b815160ff1681526020808301516001600160781b031690820152604081016108b7565b600060c0828403121561348657600080fd5b61348e6131ea565b90508135815260208201356134a28161325f565b602082015260408201356134b58161325f565b80604083015250606082013560608201526080820135608082015260a08201356001600160401b038111156134e957600080fd5b6134f58482850161338a565b60a08301525092915050565b60006020828403121561351357600080fd5b81356001600160401b0381111561352957600080fd5b612eaf84828501613474565b60006020828403121561354757600080fd5b5035919050565b602080825282518282018190526000919060409081850190868401855b8281101561359d57815180516001600160a01b039081168652908701511686850152928401929085019060010161356b565b5091979650505050505050565b6000602082840312156135bc57600080fd5b8135611b018161325f565b600082601f8301126135d857600080fd5b813560206135e86132a58361323c565b82815260059290921b8401810191818101908684111561360757600080fd5b8286015b8481101561362b57803561361e8161325f565b835291830191830161360b565b509695505050505050565b60008060006060848603121561364b57600080fd5b83356001600160401b038082111561366257600080fd5b61366e8783880161338a565b945060208601359350604086013591508082111561368b57600080fd5b50613698868287016135c7565b9150509250925092565b600080600080608085870312156136b857600080fd5b8435935060208501356136ca8161325f565b92506040850135915060608501356001600160401b038111156136ec57600080fd5b6136f88782880161338a565b91505092959194509250565b6020808252825182820181905260009190848201906040850190845b818110156137455783516001600160a01b031683529284019291840191600101613720565b50909695505050505050565b60006020828403121561376357600080fd5b81356001600160401b0381111561377957600080fd5b612eaf848285016135c7565b6000806040838503121561379857600080fd5b8235915060208301356137aa8161325f565b809150509250929050565b600082601f8301126137c657600080fd5b813560206137d66132a58361323c565b82815260069290921b840181019181810190868411156137f557600080fd5b8286015b8481101561362b57604081890312156138125760008081fd5b61381a6131c8565b813581528482013560ff811681146138325760008081fd5b818601528352918301916040016137f9565b60006138526132a58461323c565b8381529050602080820190600585811b85018781111561387157600080fd5b855b818110156139465780356001600160401b03808211156138935760008081fd5b908801906040828c0312156138a85760008081fd5b6138b06131c8565b82356138bb8161325f565b815282870135828111156138cf5760008081fd5b8084019350508b601f8401126138e757600091508182fd5b823591506138f76132a58361323c565b82815291861b8301870191878101908d8411156139145760008081fd5b938801935b8385101561393257843582529388019390880190613919565b828901525087525050938301938301613873565b50505050509392505050565b600082601f83011261396357600080fd5b611b0183833560208501613844565b60008060008060008060c0878903121561398b57600080fd5b61399487613274565b95506139a260208801613274565b945060408701356001600160401b03808211156139be57600080fd5b6139ca8a838b016137b5565b955060608901359150808211156139e057600080fd5b6139ec8a838b01613952565b94506080890135915080821115613a0257600080fd5b613a0e8a838b01613284565b935060a0890135915080821115613a2457600080fd5b50613a3189828a016135c7565b9150509295509295509295565b600060208284031215613a5057600080fd5b81356001600160401b03811115613a6657600080fd5b8201601f81018413613a7757600080fd5b612eaf84823560208401613844565b600060208284031215613a9857600080fd5b81356001600160401b03811115613aae57600080fd5b612eaf84828501613952565b60008060408385031215613acd57600080fd5b82356001600160401b03811115613ae357600080fd5b613aef85828601613474565b95602094909401359450505050565b60006020808385031215613b1157600080fd5b82356001600160401b03811115613b2757600080fd5b8301601f81018513613b3857600080fd5b8035613b466132a58261323c565b81815260069190911b82018301908381019087831115613b6557600080fd5b928401925b828410156131375760408489031215613b835760008081fd5b613b8b6131c8565b84358152858501356001600160781b0381168114613ba95760008081fd5b8187015282526040939093019290840190613b6a565b600080600060608486031215613bd457600080fd5b8335613bdf8161325f565b92506020840135613bef8161325f565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b6020810160038310613c3857634e487b7160e01b600052602160045260246000fd5b91905290565b6020808252825182820181905260009190848201906040850190845b8181101561374557835183529284019291840191600101613c5a565b60008060408385031215613c8957600080fd5b82356001600160401b03811115613c9f57600080fd5b613aef8582860161338a565b60008060408385031215613cbe57600080fd5b8235613cc98161325f565b946020939093013593505050565b600060208284031215613ce957600080fd5b81356001600160401b03811115613cff57600080fd5b612eaf848285016137b5565b60005b83811015613d26578181015183820152602001613d0e565b50506000910152565b60008151808452613d47816020860160208601613d0b565b601f01601f19169290920160200192915050565b602081526000611b016020830184613d2f565b60018060a01b0384168152826020820152606060408201526000613d956060830184613d2f565b95945050505050565b805182526000602082015160018060a01b0380821660208601528060408501511660408601525050606082015160608401526080820151608084015260a082015160c060a0850152612eaf60c0850182613d2f565b838152606060208201526000613e0c6060830185613d9e565b90508215156040830152949350505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156108b7576108b7613e1e565b634e487b7160e01b600052603260045260246000fd5b600060018201613e6f57613e6f613e1e565b5060010190565b602081526000611b016020830184613d9e565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b600060ff821660ff8103613eed57613eed613e1e565b60010192915050565b805182526000602082015160406020850152612eaf6040850182613d2f565b838152606060208201526000613f2e6060830185613ef6565b905060ff83166040830152949350505050565b60008251613f53818460208701613d0b565b9190910192915050565b600082601f830112613f6e57600080fd5b8151613f7c6132a582613363565b818152846020838601011115613f9157600080fd5b612eaf826020830160208701613d0b565b600060208284031215613fb457600080fd5b81516001600160401b0380821115613fcb57600080fd5b9083019060408286031215613fdf57600080fd5b613fe76131c8565b82518152602083015182811115613ffd57600080fd5b61344287828601613f5d565b60018060a01b0385168152836020820152826040820152608060608201526000612cb86080830184613d2f565b85815260a06020820152600061404f60a0830187613d2f565b604083018690526001600160a01b038516606084015282810360808401526140778185613d2f565b98975050505050505050565b602081526000611b016020830184613ef6565b818103818111156108b7576108b7613e1e565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156140d157600080fd5b81516001600160401b03808211156140e857600080fd5b9083019060c082860312156140fc57600080fd5b6141046131ea565b8251815260208301516141168161325f565b602082015260408301516141298161325f565b80604083015250606083015160608201526080830151608082015260a08301518281111561415657600080fd5b61416287828601613f5d565b60a08301525095945050505050565b60006020828403121561418357600080fd5b81518015158114611b0157600080fdfea2646970667358221220f254ff44a83cd67c6ee2e70a17a1ccf38432a4a1e66aa3f886952537a74ea17964736f6c63430008130033

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