ETH Price: $2,503.06 (-0.41%)

Contract

0x92F4736b72D131D836B3e4d4C3C23fE53150Ce4d
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block From To
202884332024-07-12 5:47:59113 days ago1720763279  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CrossChainControllerUpgradeRev3

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 27 : CrossChainController.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.8;

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

/**
 * @title CrossChainControllerUpgradeRev3
 * @author BGD Labs
 * @notice CrossChainController Revision 3. 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
 * @dev it initializes the new implementation with the addition of the required confirmations for all destination networks supported
 */
contract CrossChainControllerUpgradeRev3 is CrossChainController, IReinitialize {
  /// @inheritdoc IReinitialize
  function initializeRevision(
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) external reinitializer(3) {
    _updateOptimalBandwidthByChain(optimalBandwidthByChain);
  }
}

File 2 of 27 : 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,
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) external initializer {
    _baseInitialize(
      owner,
      guardian,
      initialRequiredConfirmations,
      receiverBridgeAdaptersToAllow,
      forwarderBridgeAdaptersToEnable,
      sendersToApprove,
      optimalBandwidthByChain
    );
  }
}

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

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

/**
 * @title IReinitialize
 * @author BGD Labs
 * @notice interface containing re initialization method
 */
interface IReinitialize {
  /**
   * @notice method called to re initialize the proxy
   * @param optimalBandwidthByChain array of optimal numbers of bridge adapters to use to send a message to receiver chain
   */
  function initializeRevision(
    ICrossChainForwarder.OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) external;
}

File 4 of 27 : 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
   * @param optimalBandwidthByChain array of optimal numbers of bridge adapters to use to send a message to receiver chain
   */
  function initialize(
    address owner,
    address guardian,
    ConfirmationInput[] memory initialRequiredConfirmations,
    ReceiverBridgeAdapterConfigInput[] memory receiverBridgeAdaptersToAllow,
    ForwarderBridgeAdapterConfigInput[] memory forwarderBridgeAdaptersToEnable,
    address[] memory sendersToApprove,
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) external;
}

File 5 of 27 : 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),
      new OptimalBandwidthByChain[](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,
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) 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
      optimalBandwidthByChain
    );
  }

  /// @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 6 of 27 : 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 containing the optimal bandwidth for communication with a receiver chain id
   * @param chainId id of the receiver chain
   * @param optimalBandwidth optimal number of bridge adapters to use to send a message to receiver chain
   */
  struct OptimalBandwidthByChain {
    uint256 chainId;
    uint256 optimalBandwidth;
  }

  /**
   * @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 the optimal bandwidth is updated for a specified receiver chain
   * @param chainId id of the receiver chain that gets the new optimal bandwidth
   * @param optimalBandwidth optimal number of adapters to use for sending a message to a receiver chain
   */
  event OptimalBandwidthUpdated(uint256 indexed chainId, uint256 optimalBandwidth);

  /**
   * @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);

  /**
   * @notice method to update the optimal bandwidth for communication with a receiver chain
   * @param optimalBandwidthByChain array of objects containing the optimal bandwidth for a specified
            receiver chain id
   */
  function updateOptimalBandwidthByChain(
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) external;

  /**
   * @notice method to get the optimal bandwidth for communication with the receiver chain
   * @param chainId id of the receiver chain to get the optimal bandwidth from
   * @return optimal bandwidth of the receiver chain
   */
  function getOptimalBandwidthByChain(uint256 chainId) external view returns (uint256);
}

File 7 of 27 : 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 8 of 27 : 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 9 of 27 : 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 virtual onlyRescueGuardian {
    IERC20(erc20Token).safeTransfer(to, amount);

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

  /// @inheritdoc IRescuable
  function emergencyEtherTransfer(address to, uint256 amount) external virtual 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 10 of 27 : 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 11 of 27 : 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 12 of 27 : 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';
import {Utils} from './libs/Utils.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;

  // configuration to limit bandwidth to only send via X bridge adapters out of the total allowed bridge adapters for
  // the specified chain
  // chainId => optimalBandwidth
  mapping(uint256 => uint256) internal _optimalBandwidthByChain;

  // storage gap allocation to be used for later updates. This way storage can be added on parent contract without
  // overwriting storage on child
  uint256[49] 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,
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) {
    _configureForwarderBasics(
      bridgeAdaptersToEnable,
      new BridgeAdapterToDisable[](0),
      sendersToApprove,
      new address[](0),
      optimalBandwidthByChain
    );
  }

  /// @inheritdoc ICrossChainForwarder
  function getOptimalBandwidthByChain(uint256 chainId) external view returns (uint256) {
    return _optimalBandwidthByChain[chainId];
  }

  /// @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 = _getShuffledBridgeAdaptersByChain(
      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);

    // As envelope has not ben previously sent, we need to get the optimalBandwidth shuffled bridge adapters array again.
    ChainIdBridgeConfig[] memory bridgeAdapters = _getShuffledBridgeAdaptersByChain(
      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);
  }

  /// @inheritdoc ICrossChainForwarder
  function updateOptimalBandwidthByChain(
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) external onlyOwner {
    _updateOptimalBandwidthByChain(optimalBandwidthByChain);
  }

  /**
   * @notice method to get a shuffled array of forwarder bridge adapters configurations
   * @param destinationChainId id of the destination chain to get the adapters that communicate to it
   * @return a shuffled array of the forwarder configurations for a destination chain
   */
  function _getShuffledBridgeAdaptersByChain(
    uint256 destinationChainId
  ) internal view returns (ChainIdBridgeConfig[] memory) {
    uint256 optimalBandwidth = _optimalBandwidthByChain[destinationChainId];
    ChainIdBridgeConfig[] storage forwarderAdapters = _bridgeAdaptersByChain[destinationChainId];

    // If configured optimal bandwidth for a destination network are set to 0 or are bigger than current adapters,
    // it will use all the adapters available. This way there would be no way of breaking forwarding communication
    // by setting wrong configuration.
    if (optimalBandwidth == 0 || optimalBandwidth >= forwarderAdapters.length) {
      return forwarderAdapters;
    }

    uint256[] memory shuffledIndexes = Utils.shuffleArray(
      Utils.generateIndexArray(forwarderAdapters.length),
      optimalBandwidth
    );

    ChainIdBridgeConfig[] memory selectedForwarderAdapters = new ChainIdBridgeConfig[](
      optimalBandwidth
    );

    for (uint256 i = 0; i < optimalBandwidth; i++) {
      selectedForwarderAdapters[i] = forwarderAdapters[shuffledIndexes[i]];
    }

    return selectedForwarderAdapters;
  }

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

  /**
  * @notice method to update the optimal bandwidth of a receiver chain
  * @param optimalBandwidthByChain array of objects containing the optimal bandwidth for a specified receiver chain id
  * @dev Setting optimal bandwidth to 0 means that no optimization will be applied, so all allowed bridges will be used to
         forward a message.
  */
  function _updateOptimalBandwidthByChain(
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) internal {
    for (uint256 i = 0; i < optimalBandwidthByChain.length; i++) {
      _optimalBandwidthByChain[optimalBandwidthByChain[i].chainId] = optimalBandwidthByChain[i]
        .optimalBandwidth;

      emit OptimalBandwidthUpdated(
        optimalBandwidthByChain[i].chainId,
        optimalBandwidthByChain[i].optimalBandwidth
      );
    }
  }

  /// @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,
    OptimalBandwidthByChain[] memory optimalBandwidthByChain
  ) internal {
    _enableBridgeAdapters(bridgesToEnable);
    _disableBridgeAdapters(bridgesToDisable);
    _updateSenders(sendersToEnable, true);
    _updateSenders(sendersToDisable, false);
    _updateOptimalBandwidthByChain(optimalBandwidthByChain);
  }
}

File 13 of 27 : 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 14 of 27 : 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 15 of 27 : 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 16 of 27 : 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 17 of 27 : 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 18 of 27 : 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 19 of 27 : 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 20 of 27 : 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 21 of 27 : 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 22 of 27 : Utils.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

library Utils {
  /**
   * @notice method to get a pseudo random number from previous block number, blockHash of the previous block number and an entropy value
   * @param entropy number assigned by method caller to give certain entropy to the pseudo random generation
   * @return a pseudo random number
   * @dev As this method does not offer real randomness, evaluate appropriately its usage.
   */
  function getPseudoRandom(uint256 entropy) internal view returns (uint256) {
    uint256 blockNumber = block.number - 1;
    return uint256(keccak256(abi.encodePacked(blockNumber, blockhash(blockNumber), entropy)));
  }

  /**
   * @notice method to generate an array of indexes with the specified length [0,1,2,...]
   * @param length number indicating the size of the array to generate
   * @return array of numbers with specified length
   */
  function generateIndexArray(uint256 length) internal pure returns (uint256[] memory) {
    uint256[] memory indexArray = new uint256[](length);
    for (uint256 i = 0; i < length; i++) {
      indexArray[i] = i;
    }
    return indexArray;
  }

  /**
   * @notice method to shuffle an array of forwarder configurations
   * @param arrayToShuffle array that needs to be shuffled
   * @return shuffled array of forwarder configurations
   */
  function shuffleArray(
    uint256[] memory arrayToShuffle,
    uint256 optimalBandwidth
  ) internal view returns (uint256[] memory) {
    uint256 arrayLength = arrayToShuffle.length;
    for (uint256 i = 0; i < optimalBandwidth; i++) {
      uint256 j = getPseudoRandom(i) % arrayLength;
      uint256 arrayItem = arrayToShuffle[i];
      arrayToShuffle[i] = arrayToShuffle[j];
      arrayToShuffle[j] = arrayItem;
    }
    return arrayToShuffle;
  }
}

File 23 of 27 : 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 24 of 27 : 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 25 of 27 : 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 26 of 27 : 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 27 of 27 : 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;
  }
}

Settings
{
  "remappings": [
    "solidity-utils/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/solidity-utils/src/",
    "ds-test/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/forge-std/src/",
    "openzeppelin-contracts/=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts/",
    "aave-helpers/=lib/aave-delivery-infrastructure/lib/aave-helpers/src/",
    "aave-address-book/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/aave-address-book/src/",
    "adi/=lib/aave-delivery-infrastructure/src/contracts/",
    "adi-scripts/=lib/aave-delivery-infrastructure/scripts/",
    "adi-tests/=lib/aave-delivery-infrastructure/tests/",
    "@aave/core-v3/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-core/",
    "@aave/periphery-v3/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-periphery/",
    "@openzeppelin/=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts/",
    "aave-delivery-infrastructure/=lib/aave-delivery-infrastructure/",
    "aave-v3-core/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-core/",
    "aave-v3-periphery/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-periphery/",
    "erc4626-tests/=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "fx-portal/=lib/aave-delivery-infrastructure/lib/fx-portal/contracts/",
    "governance-crosschain-bridges/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/governance-crosschain-bridges/",
    "hyperlane-monorepo/=lib/aave-delivery-infrastructure/lib/hyperlane-monorepo/solidity/contracts/",
    "nitro-contracts/=lib/aave-delivery-infrastructure/lib/nitro-contracts/src/",
    "openzeppelin/=lib/aave-delivery-infrastructure/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",
  "viaIR": false,
  "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":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimalBandwidth","type":"uint256"}],"name":"OptimalBandwidthUpdated","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":"getOptimalBandwidthByChain","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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[]"},{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256","name":"optimalBandwidth","type":"uint256"}],"internalType":"struct ICrossChainForwarder.OptimalBandwidthByChain[]","name":"optimalBandwidthByChain","type":"tuple[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256","name":"optimalBandwidth","type":"uint256"}],"internalType":"struct ICrossChainForwarder.OptimalBandwidthByChain[]","name":"optimalBandwidthByChain","type":"tuple[]"}],"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":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256","name":"optimalBandwidth","type":"uint256"}],"internalType":"struct ICrossChainForwarder.OptimalBandwidthByChain[]","name":"optimalBandwidthByChain","type":"tuple[]"}],"name":"updateOptimalBandwidthByChain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"whoCanRescue","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b50604080516000808252602082019092529062000051565b6040805180820190915260008082526020820152815260200190600190039081620000295790505b50604080516000808252602082019092529062000092565b604080518082019091526000815260606020820152815260200190600190039081620000695790505b506040805160008082526020820190925290620000d8565b6040805160608101825260008082526020808301829052928201528252600019909201910181620000aa5790505b506040805160008082526020820181815282840190935290919062000120565b6040805180820190915260008082526020820152815260200190600190039081620000f85790505b506200012c33620001fb565b62000137336200024b565b6040805160008082526020820190925262000197918591906200017e565b604080518082019091526000815260606020820152815260200190600190039081620001555790505b50604080516000815260208101909152859085620002ac565b505060408051600080825260208201909252620001e892508391620001e0565b604080518082019091526000815260606020820152815260200190600190039081620001b75790505b5084620002ee565b50620001f5905062000318565b62001331565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad909910160405180910390a15050565b620002b785620003db565b620002c2846200067d565b620002cf8360016200096d565b620002dc8260006200096d565b620002e78162000aad565b5050505050565b620002fb83600162000ba2565b6200030882600062000ba2565b620003138162000e42565b505050565b607154610100900460ff1615620003865760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b60648201526084015b60405180910390fd5b60715460ff9081161015620003d9576071805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b60005b815181101562000679576000828281518110620003ff57620003ff62001244565b6020026020010151905060006001600160a01b031681602001516001600160a01b0316141580156200043a575080516001600160a01b031615155b604051806040016040528060018152602001600d60fa1b81525090620004755760405162461bcd60e51b81526004016200037d919062001280565b506040808201516000908152600760205290812090805b825481101562000568576000838281548110620004ad57620004ad62001244565b60009182526020909120865160029092020160018101549092506001600160a01b039182169116036200055257602085015181546001600160a01b03908116911614620005475760208581015182546001600160a01b0319166001600160a01b03918216908117845587516040808a01519051928352600194919093169291600080516020620059f4833981519152910160405180910390a45b600192505062000568565b50806200055f81620012cb565b9150506200048c565b5080620006605782516040805160048152602481018252602080820180516001600160e01b039081166352d1043d60e01b1790915283518085019094526002845261199960f11b91840191909152620005c493929062000f5c16565b50604080518082018252602085810180516001600160a01b03908116845287518116838501908152875460018082018a5560008a81528690209651600290920290960180549184166001600160a01b0319928316178155915191860180549284169290911691909117905587518886015192519551958216865293949316929091600080516020620059f4833981519152910160405180910390a45b50505080806200067090620012cb565b915050620003de565b5050565b60005b8151811015620006795760005b828281518110620006a257620006a262001244565b602002602001015160200151518110156200095757600060076000858581518110620006d257620006d262001244565b6020026020010151602001518481518110620006f257620006f262001244565b60200260200101518152602001908152602001600020905060005b81548110156200093f578484815181106200072c576200072c62001244565b6020026020010151600001516001600160a01b031682828154811062000756576200075662001244565b60009182526020909120600160029092020101546001600160a01b0316036200092a57600082828154811062000790576200079062001244565b600091825260209091206002909102015483546001600160a01b0390911691508390620007c090600190620012e7565b81548110620007d357620007d362001244565b9060005260206000209060020201838381548110620007f657620007f662001244565b60009182526020909120825460029092020180546001600160a01b039283166001600160a01b03199182161782556001938401549390910180549390921692169190911790558254839080620008505762000850620012fd565b60008281526020812060026000199093019283020180546001600160a01b0319908116825560019190910180549091169055915586518790879081106200089b576200089b62001244565b6020026020010151600001516001600160a01b0316878781518110620008c557620008c562001244565b6020026020010151602001518681518110620008e557620008e562001244565b6020026020010151600080516020620059f4833981519152846040516200091b91906001600160a01b0391909116815260200190565b60405180910390a4506200093f565b806200093681620012cb565b9150506200070d565b505080806200094e90620012cb565b9150506200068d565b50806200096481620012cb565b91505062000680565b60005b8251811015620003135760006001600160a01b03168382815181106200099a576200099a62001244565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161199b60f11b81525090620009e95760405162461bcd60e51b81526004016200037d919062001280565b50816004600085848151811062000a045762000a0462001244565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555081151583828151811062000a5b5762000a5b62001244565b60200260200101516001600160a01b03167f626c27c1d088fd70034e681d579a5efd004c3d47a56d3ee07ad256ac7301433360405160405180910390a38062000aa481620012cb565b91505062000970565b60005b8151811015620006795781818151811062000acf5762000acf62001244565b6020026020010151602001516008600084848151811062000af45762000af462001244565b60200260200101516000015181526020019081526020016000208190555081818151811062000b275762000b2762001244565b6020026020010151600001517fa7db3ff5dbb4e968ca876b88c9cc737050842adf8bbeef18db5a8a18391cd70983838151811062000b695762000b6962001244565b60200260200101516020015160405162000b8591815260200190565b60405180910390a28062000b9981620012cb565b91505062000ab0565b60005b82518110156200031357600083828151811062000bc65762000bc662001244565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316141560405180604001604052806002815260200161062760f31b8152509062000c275760405162461bcd60e51b81526004016200037d919062001280565b5060005b81602001515181101562000e2a576000841562000ccf5762000c788360200151838151811062000c5f5762000c5f62001244565b6020026020010151603d62000fdb60201b90919060201c565b5062000cc78360000151603a60008660200151868151811062000c9f5762000c9f62001244565b6020026020010151815260200190815260200160002060010162000ff260201b90919060201c565b905062000dae565b62000d1d8360000151603a60008660200151868151811062000cf55762000cf562001244565b602002602001015181526020019081526020016000206001016200100960201b90919060201c565b905080801562000d70575062000d6e603a60008560200151858151811062000d495762000d4962001244565b602002602001015181526020019081526020016000206001016200102060201b60201c565b155b1562000dae5762000dac8360200151838151811062000d935762000d9362001244565b6020026020010151603d6200102b60201b90919060201c565b505b801562000e14578260200151828151811062000dce5762000dce62001244565b602002602001015185151584600001516001600160a01b03167f537ae69afd3600f30d8c662539017cc022c73b04db804445c9eaae801c2f4a8360405160405180910390a45b508062000e2181620012cb565b91505062000c2b565b5050808062000e3990620012cb565b91505062000ba5565b60005b81518110156200067957600082828151811062000e665762000e6662001244565b602002602001015190506000816020015160ff1611801562000eac575080516000908152603a6020526040902062000ea19060010162001020565b816020015160ff1611155b60405180604001604052806002815260200161189b60f11b8152509062000ee85760405162461bcd60e51b81526004016200037d919062001280565b506020818101805183516000908152603a8452604090819020805460ff191660ff9384161790558451925190519116815290917f799ef5c83e710778f5725ab120f43a73d21b1d98f2e1a058801728ace31275fd910160405180910390a2508062000f5381620012cb565b91505062000e45565b6060600080856001600160a01b03168560405162000f7b919062001313565b600060405180830381855af49150503d806000811462000fb8576040519150601f19603f3d011682016040523d82523d6000602084013e62000fbd565b606091505b50909250905062000fd18683838762001039565b9695505050505050565b600062000fe98383620010c1565b90505b92915050565b600062000fe9836001600160a01b038416620010c1565b600062000fe9836001600160a01b03841662001113565b600062000fec825490565b600062000fe9838362001113565b60608315620010ad578251600003620010a5576001600160a01b0385163b620010a55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200037d565b5081620010b9565b620010b9838362001217565b949350505050565b60008181526001830160205260408120546200110a5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000fec565b50600062000fec565b600081815260018301602052604081205480156200120c5760006200113a600183620012e7565b85549091506000906200115090600190620012e7565b9050818114620011bc57600086600001828154811062001174576200117462001244565b90600052602060002001549050808760000184815481106200119a576200119a62001244565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080620011d057620011d0620012fd565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505062000fec565b600091505062000fec565b815115620012285781518083602001fd5b8060405162461bcd60e51b81526004016200037d919062001280565b634e487b7160e01b600052603260045260246000fd5b60005b83811015620012775781810151838201526020016200125d565b50506000910152565b6020815260008251806020840152620012a18160408501602087016200125a565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b600060018201620012e057620012e0620012b5565b5060010190565b8181038181111562000fec5762000fec620012b5565b634e487b7160e01b600052603160045260246000fd5b60008251620013278184602087016200125a565b9190910192915050565b6146b380620013416000396000f3fe6080604052600436106102555760003560e01c80639b6c7efa11610139578063db58eaec116100b6578063eed88b8d1161007a578063eed88b8d14610840578063efe4b0ae14610860578063f2fde38b14610875578063f62b984314610895578063fc525395146108b5578063fe46a413146108d557600080fd5b8063db58eaec14610790578063e01658d9146107c0578063e02146b8146107e0578063e3a95a5a14610800578063ed68595a1461082057600080fd5b8063a4757b0f116100fd578063a4757b0f14610598578063aa3f85c8146106a6578063c37255f2146106e3578063c4bffe2b14610703578063c71cca161461072557600080fd5b80639b6c7efa146105f65780639d0cb9d414610626578063a25d389214610646578063a2711ff414610666578063a3d5b2551461068657600080fd5b806355c4fed4116101d2578063715018a611610196578063715018a6146105195780637670d1d81461052e57806376e5379a1461054e5780638da5cb5b1461059857806390f7af54146105b6578063917cbb9b146105d657600080fd5b806355c4fed41461041c5780635b9d97c614610451578063635f7c031461047e578063654a812b1461049e5780636e74ebe8146104b357600080fd5b80633805e84e116102195780633805e84e146103415780633eb59f601461038a578063436bd103146103aa578063452a9320146103ca57806350311090146103fc57600080fd5b80630a234b15146102615780630fb9ca41146102835780631947051e146102b957806334987236146102d957806334f7870c1461031457600080fd5b3661025c57005b600080fd5b34801561026d57600080fd5b5061028161027c36600461371e565b6108f5565b005b34801561028f57600080fd5b506102a361029e3660046137ca565b610909565b6040516102b09190613840565b60405180910390f35b3480156102c557600080fd5b506102816102d43660046138f0565b61092f565b3480156102e557600080fd5b506103066102f4366004613924565b60009081526008602052604090205490565b6040519081526020016102b0565b34801561032057600080fd5b5061033461032f366004613924565b610a73565b6040516102b0919061393d565b34801561034d57600080fd5b5061037a61035c366004613999565b6001600160a01b031660009081526004602052604090205460ff1690565b60405190151581526020016102b0565b34801561039657600080fd5b506102816103a5366004613a25565b610afe565b3480156103b657600080fd5b5061037a6103c53660046138f0565b610ebf565b3480156103d657600080fd5b506001546001600160a01b03165b6040516001600160a01b0390911681526020016102b0565b34801561040857600080fd5b50610281610417366004613b10565b610ecd565b34801561042857600080fd5b5061043c610437366004613b44565b610f66565b604080519283526020830191909152016102b0565b34801561045d57600080fd5b5061047161046c366004613924565b61114d565b6040516102b09190613ba6565b34801561048a57600080fd5b50610281610499366004613db0565b61116a565b3480156104aa57600080fd5b50600354610306565b3480156104bf57600080fd5b506102a36104ce366004613924565b6040805180820190915260008082526020820152506000908152603a602090815260409182902082518084019093525460ff8116835261010090046001600160781b03169082015290565b34801561052557600080fd5b50610281611242565b34801561053a57600080fd5b50610281610549366004613ea2565b611256565b34801561055a57600080fd5b5061037a610569366004613ed6565b6000828152603b602090815260408083206001600160a01b038516845260010190915290205460ff1692915050565b3480156105a457600080fd5b506000546001600160a01b03166103e4565b3480156105c257600080fd5b506102816105d1366004613ea2565b611269565b3480156105e257600080fd5b506102816105f1366004613f06565b61127c565b34801561060257600080fd5b5061037a610611366004613924565b60009081526006602052604090205460ff1690565b34801561063257600080fd5b50610281610641366004613f4e565b61128d565b34801561065257600080fd5b50610306610661366004613f82565b6112a0565b34801561067257600080fd5b50610281610681366004613fc6565b6113db565b34801561069257600080fd5b506102816106a1366004614087565b6113ec565b3480156106b257600080fd5b506106d66106c1366004613924565b6000908152603c602052604090205460ff1690565b6040516102b091906140de565b3480156106ef57600080fd5b5061037a6106fe3660046137ca565b6114b2565b34801561070f57600080fd5b506107186114c0565b6040516102b09190614106565b34801561073157600080fd5b506102a3610740366004613924565b6040805180820190915260008082526020820152506040805180820182526000838152603b60208181529382205460ff811684529490915282526101009092046001600160781b03169082015290565b34801561079c57600080fd5b5061037a6107ab366004613924565b60009081526005602052604090205460ff1690565b3480156107cc57600080fd5b506106d66107db3660046138f0565b6114cc565b3480156107ec57600080fd5b506102816107fb366004613b10565b6114da565b34801561080c57600080fd5b5061028161081b366004613f4e565b6114eb565b34801561082c57600080fd5b5061028161083b36600461413e565b6114fe565b34801561084c57600080fd5b5061028161085b366004614173565b6118ce565b34801561086c57600080fd5b50600254610306565b34801561088157600080fd5b50610281610890366004613999565b611a15565b3480156108a157600080fd5b5061037a6108b0366004614173565b611a8b565b3480156108c157600080fd5b506102816108d0366004613999565b611aad565b3480156108e157600080fd5b506102816108f036600461419f565b611abe565b6108fd611acf565b61090681611b29565b50565b604080518082019091526000808252602082015261092961074083611dcd565b92915050565b600061093a82611de4565b905060016000828152603c602052604090205460ff166002811115610961576109616140c8565b1460405180604001604052806002815260200161191960f11b815250906109a45760405162461bcd60e51b815260040161099b9190614223565b60405180910390fd5b506000818152603c6020908152604091829020805460ff191660021790558382015190840151606085015160a08601519351630a81a65d60e11b81526001600160a01b03909316936315034cba93610a0193929190600401614236565b600060405180830381600087803b158015610a1b57600080fd5b505af1158015610a2f573d6000803e3d6000fd5b505050507fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab81836001604051610a67939291906142bb565b60405180910390a15050565b606060076000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610af3576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610aa8565b505050509050919050565b610b06611df0565b8251602084012060009060008181526006602052604090205490915060ff1660405180604001604052806002815260200161313960f01b81525090610b5e5760405162461bcd60e51b815260040161099b9190614223565b506000610b6a85611e5f565b90506000610b7782611e88565b905060006007600083608001518152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610bfd576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610bb2565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b81525090610c415760405162461bcd60e51b815260040161099b9190614223565b50600085516001600160401b03811115610c5d57610c5d613579565b604051908082528060200260200182016040528015610ca257816020015b6040805180820190915260008082526020820152815260200190600190039081610c7b5790505b50905060005b8651811015610e5a576000610cbe8260016142fc565b90505b8751811015610d5e57878181518110610cdc57610cdc61430f565b60200260200101516001600160a01b0316888381518110610cff57610cff61430f565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161323160f01b81525090610d4b5760405162461bcd60e51b815260040161099b9190614223565b5080610d5681614325565b915050610cc1565b506000805b8451811015610e0d57848181518110610d7e57610d7e61430f565b6020026020010151602001516001600160a01b0316898481518110610da557610da561430f565b60200260200101516001600160a01b031603610dfb57848181518110610dcd57610dcd61430f565b6020026020010151848481518110610de757610de761430f565b602002602001018190525060019150610e0d565b80610e0581614325565b915050610d63565b50604080518082019091526002815261062760f31b602082015281610e455760405162461bcd60e51b815260040161099b9190614223565b50508080610e5290614325565b915050610ca8565b506000610e77610e6986611e9d565b878b87608001518c87611eb0565b90508060405180604001604052806002815260200161032360f41b81525090610eb35760405162461bcd60e51b815260040161099b9190614223565b50505050505050505050565b60006109296107ab83611de4565b607154600390610100900460ff16158015610eef575060715460ff8083169116105b610f0b5760405162461bcd60e51b815260040161099b9061433e565b6071805461ffff191660ff831617610100179055610f288261205a565b6071805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610a67565b33600090815260046020526040812054819060ff16604051806040016040528060018152602001601960f91b81525090610fb35760405162461bcd60e51b815260040161099b9190614223565b506000610fbf8761213e565b90506000815111604051806040016040528060028152602001610c4d60f21b81525090610fff5760405162461bcd60e51b815260040161099b9190614223565b50600280546000918261101183614325565b91905055905060006040518060c00160405280838152602001336001600160a01b03168152602001896001600160a01b031681526020014681526020018a815260200187815250905060006110658261230e565b6020808201805160009081526005909252604091829020805460ff19166001179055519051919250907f18d245f6501b267c6fc4ab6bb6f037c83d28a9ab089e79ab063162d414d2d9c9906110bb90859061438c565b60405180910390a260006110f96040518060400160405280600360008154809291906110e690614325565b909155508152845160209091015261236f565b6020808201805160009081526006835260409020805460ff1916600117905590840151905182516080870151939450611133938d8a611eb0565b50602091820151910151909a909950975050505050505050565b6000818152603a60205260409020606090610929906001016123aa565b607154610100900460ff161580801561118a5750607154600160ff909116105b806111a45750303b1580156111a4575060715460ff166001145b6111c05760405162461bcd60e51b815260040161099b9061433e565b6071805460ff1916600117905580156111e3576071805461ff0019166101001790555b6111f2888888888888886123b7565b8015611238576071805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b61124a611acf565b61125460006124e9565b565b61125e611acf565b610906816000612539565b611271611acf565b610906816001612539565b611284611acf565b61090681612669565b611295611acf565b610906816001612935565b60006112aa611df0565b60006112b58461230e565b90506112d4816020015160009081526005602052604090205460ff1690565b604051806040016040528060018152602001603360f81b8152509061130c5760405162461bcd60e51b815260040161099b9190614223565b50600061131c856080015161213e565b90506000815111604051806040016040528060028152602001610c4d60f21b8152509061135c5760405162461bcd60e51b815260040161099b9190614223565b50600061139360405180604001604052806003600081548092919061138090614325565b909155508152855160209091015261236f565b6020808201805160009081526006835260409020805460ff19166001179055908501519051825160808a01519394506113cd938987611eb0565b506020015195945050505050565b6113e3611acf565b61090681612ba0565b6000546001600160a01b0316331461143d5760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b604482015260640161099b565b6114516001600160a01b0384168383612cc9565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fc7af665d489507e14ae25ac7ab0030fc7f570869610bdd32117ea56b60ae5c61846040516114a091815260200190565b60405180910390a4505050565b905090565b600061092961061183611dcd565b60606114ad603d6123aa565b60006109296106c183611de4565b6114e2611acf565b6109068161205a565b6114f3611acf565b610906816000612935565b806115093382611a8b565b604051806040016040528060018152602001603560f81b815250906115415760405162461bcd60e51b815260040161099b9190614223565b50600061154d84611e5f565b9050600061155a82611e88565b90508381606001511480156115725750468160800151145b60405180604001604052806002815260200161333360f01b815250906115ab5760405162461bcd60e51b815260040161099b9190614223565b5060006115b783611e9d565b865160208801209091506000906000818152603b602090815260408083208a8452603a83529281902081518083019092525460ff811682526001600160781b0361010091829004811693830193909352835494955092939092900416801580611652575033600090815260018401602052604090205460ff16158015611652575081602001516001600160781b0316816001600160781b0316115b15610eb357806001600160781b0316600003611687578254610100600160801b031916610100426001600160781b0316021783555b82546000908490829061169c9060ff1661439f565b825460ff8083166101009490940a93840293021916919091179091553360008181526001878101602052604091829020805460ff1916909117905551919250908b9088907f5353716bf921d1d85f5567a99a718cc63ff1182dca5f9163d9e9b8f1fc3ac38790611711908a908e9088906143dd565b60405180910390a46000868152603c602052604081205460ff16600281111561173c5761173c6140c8565b1461174e575050505050505050505050565b825160ff161580159061176b5750826000015160ff168160ff1610155b156118c0576000868152603c6020908152604091829020805460ff19166002179055888201519089015160608a015160a08b01519351630a81a65d60e11b81526001600160a01b03909316936315034cba936117cc93929190600401614236565b600060405180830381600087803b1580156117e657600080fd5b505af19250505080156117f7575060015b611883573d808015611825576040519150601f19603f3d011682016040523d82523d6000602084013e61182a565b606091505b506000878152603c6020526040808220805460ff19166001179055517fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab91611875918a918c916142bb565b60405180910390a1506118c0565b7fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab868860016040516118b7939291906142bb565b60405180910390a15b50505050505050505b505050565b6000546001600160a01b0316331461191f5760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b604482015260640161099b565b604080516000808252602082019092526001600160a01b0384169083906040516119499190614409565b60006040518083038185875af1925050503d8060008114611986576040519150601f19603f3d011682016040523d82523d6000602084013e61198b565b606091505b50509050806119d05760405162461bcd60e51b815260206004820152601160248201527011551217d514905394d1915497d1905253607a1b604482015260640161099b565b6040518281526001600160a01b0384169033907fb7c602059992183c7b767c08204223afc99f1895fd175adf9ece23ce9f5bb8b79060200160405180910390a3505050565b611a1d611acf565b6001600160a01b038116611a825760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161099b565b610906816124e9565b6000818152603a60205260408120611aa69060010184612d1b565b9392505050565b611ab5611df0565b61090681612d3d565b611ac6611acf565b61090681612d97565b6000546001600160a01b031633146112545760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161099b565b60005b8151811015611dc9576000828281518110611b4957611b4961430f565b6020026020010151905060006001600160a01b031681602001516001600160a01b031614158015611b83575080516001600160a01b031615155b604051806040016040528060018152602001600d60fa1b81525090611bbb5760405162461bcd60e51b815260040161099b9190614223565b506040808201516000908152600760205290812090805b8254811015611cb5576000838281548110611bef57611bef61430f565b60009182526020909120865160029092020160018101549092506001600160a01b03918216911603611ca257602085015181546001600160a01b03908116911614611c985760208581015182546001600160a01b0319166001600160a01b03918216908117845587516040808a015190519283526001949190931692917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b6001925050611cb5565b5080611cad81614325565b915050611bd2565b5080611db35782516040805160048152602481018252602080820180516001600160e01b03166352d1043d60e01b17905282518084019093526002835261199960f11b90830152611d069291612ea4565b50604080518082018252602085810180516001600160a01b03908116845287518116838501908152875460018082018a5560008a81528690209651600290920290960180549184166001600160a01b03199283161781559151918601805492841692909116919091179055875188860151925195519582168652939493169290917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b5050508080611dc190614325565b915050611b2c565b5050565b600080611dd98361236f565b602001519392505050565b600080611dd98361230e565b6000546001600160a01b0316331480611e1357506001546001600160a01b031633145b6112545760405162461bcd60e51b815260206004820152601960248201527f4f4e4c595f42595f4f574e45525f4f525f475541524449414e00000000000000604482015260640161099b565b60408051808201909152600081526060602082015281806020019051810190610929919061446a565b611e90613531565b6109298260200151612f1c565b6020808201518051910120600090610929565b600080805b835181101561204e57600080858381518110611ed357611ed361430f565b6020026020010151602001516001600160a01b03166336da7a0660e01b878581518110611f0257611f0261430f565b602002602001015160000151898b8d604051602401611f2494939291906144d1565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611f629190614409565b600060405180830381855af49150503d8060008114611f9d576040519150601f19603f3d011682016040523d82523d6000602084013e611fa2565b606091505b50915091508115611fb257600193505b811515868481518110611fc757611fc761430f565b6020026020010151602001516001600160a01b03168c7f935aa87d643578e6395c90fdbd5d50ffee5f2c1f6ce2cd01274740412bb679f48d8d8d8c8a815181106120135761201361430f565b602002602001015160000151886040516120319594939291906144fe565b60405180910390a45050808061204690614325565b915050611eb5565b50979650505050505050565b60005b8151811015611dc9578181815181106120785761207861430f565b6020026020010151602001516008600084848151811061209a5761209a61430f565b6020026020010151600001518152602001908152602001600020819055508181815181106120ca576120ca61430f565b6020026020010151600001517fa7db3ff5dbb4e968ca876b88c9cc737050842adf8bbeef18db5a8a18391cd7098383815181106121095761210961430f565b60200260200101516020015160405161212491815260200190565b60405180910390a28061213681614325565b91505061205d565b60008181526008602090815260408083205460079092529091206060919081158061216a575080548210155b156121e85780805480602002602001604051908101604052809291908181526020016000905b828210156121db576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101612190565b5050505092505050919050565b60006122006121fa8380549050612f38565b84612fc2565b90506000836001600160401b0381111561221c5761221c613579565b60405190808252806020026020018201604052801561226157816020015b604080518082019091526000808252602082015281526020019060019003908161223a5790505b50905060005b8481101561230457838382815181106122825761228261430f565b60200260200101518154811061229a5761229a61430f565b60009182526020918290206040805180820190915260029092020180546001600160a01b039081168352600190910154169181019190915282518390839081106122e6576122e661430f565b602002602001018190525080806122fc90614325565b915050612267565b5095945050505050565b60408051808201909152606081526000602082015260408051808201909152606081526000602082015282604051602001612349919061438c565b60408051808303601f190181529190528082528051602090910120602082015292915050565b60408051808201909152606081526000602082015260408051808201909152606081526000602082015282604051602001612349919061454b565b60606000611aa68361307d565b607154610100900460ff16158080156123d75750607154600160ff909116105b806123f15750303b1580156123f1575060715460ff166001145b61240d5760405162461bcd60e51b815260040161099b9061433e565b6071805460ff191660011790558015612430576071805461ff0019166101001790555b612439886124e9565b61244287612d3d565b6040805160008082526020820190925261248d91879190612486565b60408051808201909152600081526060602082015281526020019060019003908161245e5790505b50886130d9565b604080516000808252602082019092526111f2918691906124d1565b6040805180820190915260008152606060208201528152602001906001900390816124a95790505b506040805160008152602081019091528690866130f8565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005b82518110156118c95760006001600160a01b03168382815181106125625761256261430f565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161199b60f11b815250906125ae5760405162461bcd60e51b815260040161099b9190614223565b5081600460008584815181106125c6576125c661430f565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555081151583828151811061261a5761261a61430f565b60200260200101516001600160a01b03167f626c27c1d088fd70034e681d579a5efd004c3d47a56d3ee07ad256ac7301433360405160405180910390a38061266181614325565b91505061253c565b60005b8151811015611dc95760005b82828151811061268a5761268a61430f565b60200260200101516020015151811015612922576000600760008585815181106126b6576126b661430f565b60200260200101516020015184815181106126d3576126d361430f565b60200260200101518152602001908152602001600020905060005b815481101561290d578484815181106127095761270961430f565b6020026020010151600001516001600160a01b03168282815481106127305761273061430f565b60009182526020909120600160029092020101546001600160a01b0316036128fb5760008282815481106127665761276661430f565b600091825260209091206002909102015483546001600160a01b03909116915083906127949060019061455e565b815481106127a4576127a461430f565b90600052602060002090600202018383815481106127c4576127c461430f565b60009182526020909120825460029092020180546001600160a01b039283166001600160a01b0319918216178255600193840154939091018054939092169216919091179055825483908061281b5761281b614571565b60008281526020812060026000199093019283020180546001600160a01b0319908116825560019190910180549091169055915586518790879081106128635761286361430f565b6020026020010151600001516001600160a01b031687878151811061288a5761288a61430f565b60200260200101516020015186815181106128a7576128a761430f565b60200260200101517f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d846040516128ed91906001600160a01b0391909116815260200190565b60405180910390a45061290d565b8061290581614325565b9150506126ee565b5050808061291a90614325565b915050612678565b508061292d81614325565b91505061266c565b60005b82518110156118c95760008382815181106129555761295561430f565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316141560405180604001604052806002815260200161062760f31b815250906129b35760405162461bcd60e51b815260040161099b9190614223565b5060005b816020015151811015612b8b5760008415612a4e576129fd836020015183815181106129e5576129e561430f565b6020026020010151603d61313090919063ffffffff16565b50612a478360000151603a600086602001518681518110612a2057612a2061430f565b6020026020010151815260200190815260200160002060010161313c90919063ffffffff16565b9050612b16565b612a978360000151603a600086602001518681518110612a7057612a7061430f565b6020026020010151815260200190815260200160002060010161315190919063ffffffff16565b9050808015612ade5750612adc603a600085602001518581518110612abe57612abe61430f565b60200260200101518152602001908152602001600020600101613166565b155b15612b1657612b1483602001518381518110612afc57612afc61430f565b6020026020010151603d61317090919063ffffffff16565b505b8015612b785782602001518281518110612b3257612b3261430f565b602002602001015185151584600001516001600160a01b03167f537ae69afd3600f30d8c662539017cc022c73b04db804445c9eaae801c2f4a8360405160405180910390a45b5080612b8381614325565b9150506129b7565b50508080612b9890614325565b915050612938565b60005b8151811015611dc9576000828281518110612bc057612bc061430f565b60209081029190910181015180516000908152603a83526040902054918101519092506001600160781b0361010090920482169116118015612c0f57504281602001516001600160781b031611155b604051806040016040528060018152602001601b60f91b81525090612c475760405162461bcd60e51b815260040161099b9190614223565b506020818101805183516000908152603a84526040908190208054610100600160801b0319166101006001600160781b03948516021790558451925190519116815290917f79b1ca301c237cd649b2d35eb6f0873650079b8bb613a17279bbf80332754ddd910160405180910390a25080612cc181614325565b915050612ba3565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526118c990849061317c565b6001600160a01b03811660009081526001830160205260408120541515611aa6565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad9099101610a67565b60005b8151811015611dc9576000828281518110612db757612db761430f565b602002602001015190506000816020015160ff16118015612dfa575080516000908152603a60205260409020612def90600101613166565b816020015160ff1611155b60405180604001604052806002815260200161189b60f11b81525090612e335760405162461bcd60e51b815260040161099b9190614223565b506020818101805183516000908152603a8452604090819020805460ff191660ff9384161790558451925190519116815290917f799ef5c83e710778f5725ab120f43a73d21b1d98f2e1a058801728ace31275fd910160405180910390a25080612e9c81614325565b915050612d9a565b6060600080856001600160a01b031685604051612ec19190614409565b600060405180830381855af49150503d8060008114612efc576040519150601f19603f3d011682016040523d82523d6000602084013e612f01565b606091505b5091509150612f12868383876131df565b9695505050505050565b612f24613531565b818060200190518101906109299190614587565b60606000826001600160401b03811115612f5457612f54613579565b604051908082528060200260200182016040528015612f7d578160200160208202803683370190505b50905060005b83811015612fbb5780828281518110612f9e57612f9e61430f565b602090810291909101015280612fb381614325565b915050612f83565b5092915050565b815160609060005b8381101561307457600082612fde83613260565b612fe89190614639565b90506000868381518110612ffe57612ffe61430f565b6020026020010151905086828151811061301a5761301a61430f565b60200260200101518784815181106130345761303461430f565b602002602001018181525050808783815181106130535761305361430f565b6020026020010181815250505050808061306c90614325565b915050612fca565b50929392505050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156130cd57602002820191906000526020600020905b8154815260200190600101908083116130b9575b50505050509050919050565b6130e4836001612935565b6130ef826000612935565b6118c981612d97565b61310185611b29565b61310a84612669565b613115836001612539565b613120826000612539565b6131298161205a565b5050505050565b6000611aa683836132a6565b6000611aa6836001600160a01b0384166132a6565b6000611aa6836001600160a01b0384166132f5565b6000610929825490565b6000611aa683836132f5565b60006131916001600160a01b038416836133e8565b905080516000141580156131b65750808060200190518101906131b4919061465b565b155b156118c957604051635274afe760e01b81526001600160a01b038416600482015260240161099b565b6060831561324e578251600003613247576001600160a01b0385163b6132475760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161099b565b5081613258565b613258838361342c565b949350505050565b60008061326e60014361455e565b604080516020808201849052924081830152606080820196909652815180820390960186526080019052835193019290922092915050565b60008181526001830160205260408120546132ed57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610929565b506000610929565b600081815260018301602052604081205480156133de57600061331960018361455e565b855490915060009061332d9060019061455e565b905081811461339257600086600001828154811061334d5761334d61430f565b90600052602060002001549050808760000184815481106133705761337061430f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806133a3576133a3614571565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610929565b6000915050610929565b6060611aa6838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250613456565b81511561343c5781518083602001fd5b8060405162461bcd60e51b815260040161099b9190614223565b6060824710156134b75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161099b565b600080866001600160a01b031685876040516134d39190614409565b60006040518083038185875af1925050503d8060008114613510576040519150601f19603f3d011682016040523d82523d6000602084013e613515565b606091505b5091509150613526878383876131df565b979650505050505050565b6040518060c001604052806000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156135b1576135b1613579565b60405290565b604080519081016001600160401b03811182821017156135b1576135b1613579565b60405160c081016001600160401b03811182821017156135b1576135b1613579565b604051601f8201601f191681016001600160401b038111828210171561362357613623613579565b604052919050565b60006001600160401b0382111561364457613644613579565b5060051b60200190565b6001600160a01b038116811461090657600080fd5b803561366e8161364e565b919050565b600082601f83011261368457600080fd5b813560206136996136948361362b565b6135fb565b828152606092830285018201928282019190878511156136b857600080fd5b8387015b858110156137115781818a0312156136d45760008081fd5b6136dc61358f565b81356136e78161364e565b8152818601356136f68161364e565b818701526040828101359082015284529284019281016136bc565b5090979650505050505050565b60006020828403121561373057600080fd5b81356001600160401b0381111561374657600080fd5b61325884828501613673565b60006001600160401b0382111561376b5761376b613579565b50601f01601f191660200190565b600082601f83011261378a57600080fd5b813561379861369482613752565b8181528460208386010111156137ad57600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156137dc57600080fd5b81356001600160401b03808211156137f357600080fd5b908301906040828603121561380757600080fd5b61380f6135b7565b8235815260208301358281111561382557600080fd5b61383187828601613779565b60208301525095945050505050565b815160ff1681526020808301516001600160781b03169082015260408101610929565b600060c0828403121561387557600080fd5b61387d6135d9565b90508135815260208201356138918161364e565b602082015260408201356138a48161364e565b80604083015250606082013560608201526080820135608082015260a08201356001600160401b038111156138d857600080fd5b6138e484828501613779565b60a08301525092915050565b60006020828403121561390257600080fd5b81356001600160401b0381111561391857600080fd5b61325884828501613863565b60006020828403121561393657600080fd5b5035919050565b602080825282518282018190526000919060409081850190868401855b8281101561398c57815180516001600160a01b039081168652908701511686850152928401929085019060010161395a565b5091979650505050505050565b6000602082840312156139ab57600080fd5b8135611aa68161364e565b600082601f8301126139c757600080fd5b813560206139d76136948361362b565b82815260059290921b840181019181810190868411156139f657600080fd5b8286015b84811015613a1a578035613a0d8161364e565b83529183019183016139fa565b509695505050505050565b600080600060608486031215613a3a57600080fd5b83356001600160401b0380821115613a5157600080fd5b613a5d87838801613779565b9450602086013593506040860135915080821115613a7a57600080fd5b50613a87868287016139b6565b9150509250925092565b600082601f830112613aa257600080fd5b81356020613ab26136948361362b565b82815260069290921b84018101918181019086841115613ad157600080fd5b8286015b84811015613a1a5760408189031215613aee5760008081fd5b613af66135b7565b813581528482013585820152835291830191604001613ad5565b600060208284031215613b2257600080fd5b81356001600160401b03811115613b3857600080fd5b61325884828501613a91565b60008060008060808587031215613b5a57600080fd5b843593506020850135613b6c8161364e565b92506040850135915060608501356001600160401b03811115613b8e57600080fd5b613b9a87828801613779565b91505092959194509250565b6020808252825182820181905260009190848201906040850190845b81811015613be75783516001600160a01b031683529284019291840191600101613bc2565b50909695505050505050565b600082601f830112613c0457600080fd5b81356020613c146136948361362b565b82815260069290921b84018101918181019086841115613c3357600080fd5b8286015b84811015613a1a5760408189031215613c505760008081fd5b613c586135b7565b813581528482013560ff81168114613c705760008081fd5b81860152835291830191604001613c37565b6000613c906136948461362b565b8381529050602080820190600585811b850187811115613caf57600080fd5b855b81811015613d845780356001600160401b0380821115613cd15760008081fd5b908801906040828c031215613ce65760008081fd5b613cee6135b7565b8235613cf98161364e565b81528287013582811115613d0d5760008081fd5b8084019350508b601f840112613d2557600091508182fd5b82359150613d356136948361362b565b82815291861b8301870191878101908d841115613d525760008081fd5b938801935b83851015613d7057843582529388019390880190613d57565b828901525087525050938301938301613cb1565b50505050509392505050565b600082601f830112613da157600080fd5b611aa683833560208501613c82565b600080600080600080600060e0888a031215613dcb57600080fd5b613dd488613663565b9650613de260208901613663565b955060408801356001600160401b0380821115613dfe57600080fd5b613e0a8b838c01613bf3565b965060608a0135915080821115613e2057600080fd5b613e2c8b838c01613d90565b955060808a0135915080821115613e4257600080fd5b613e4e8b838c01613673565b945060a08a0135915080821115613e6457600080fd5b613e708b838c016139b6565b935060c08a0135915080821115613e8657600080fd5b50613e938a828b01613a91565b91505092959891949750929550565b600060208284031215613eb457600080fd5b81356001600160401b03811115613eca57600080fd5b613258848285016139b6565b60008060408385031215613ee957600080fd5b823591506020830135613efb8161364e565b809150509250929050565b600060208284031215613f1857600080fd5b81356001600160401b03811115613f2e57600080fd5b8201601f81018413613f3f57600080fd5b61325884823560208401613c82565b600060208284031215613f6057600080fd5b81356001600160401b03811115613f7657600080fd5b61325884828501613d90565b60008060408385031215613f9557600080fd5b82356001600160401b03811115613fab57600080fd5b613fb785828601613863565b95602094909401359450505050565b60006020808385031215613fd957600080fd5b82356001600160401b03811115613fef57600080fd5b8301601f8101851361400057600080fd5b803561400e6136948261362b565b81815260069190911b8201830190838101908783111561402d57600080fd5b928401925b82841015613526576040848903121561404b5760008081fd5b6140536135b7565b84358152858501356001600160781b03811681146140715760008081fd5b8187015282526040939093019290840190614032565b60008060006060848603121561409c57600080fd5b83356140a78161364e565b925060208401356140b78161364e565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b602081016003831061410057634e487b7160e01b600052602160045260246000fd5b91905290565b6020808252825182820181905260009190848201906040850190845b81811015613be757835183529284019291840191600101614122565b6000806040838503121561415157600080fd5b82356001600160401b0381111561416757600080fd5b613fb785828601613779565b6000806040838503121561418657600080fd5b82356141918161364e565b946020939093013593505050565b6000602082840312156141b157600080fd5b81356001600160401b038111156141c757600080fd5b61325884828501613bf3565b60005b838110156141ee5781810151838201526020016141d6565b50506000910152565b6000815180845261420f8160208601602086016141d3565b601f01601f19169290920160200192915050565b602081526000611aa660208301846141f7565b60018060a01b038416815282602082015260606040820152600061425d60608301846141f7565b95945050505050565b805182526000602082015160018060a01b0380821660208601528060408501511660408601525050606082015160608401526080820151608084015260a082015160c060a085015261325860c08501826141f7565b8381526060602082015260006142d46060830185614266565b90508215156040830152949350505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610929576109296142e6565b634e487b7160e01b600052603260045260246000fd5b600060018201614337576143376142e6565b5060010190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602081526000611aa66020830184614266565b600060ff821660ff81036143b5576143b56142e6565b60010192915050565b80518252600060208201516040602085015261325860408501826141f7565b8381526060602082015260006143f660608301856143be565b905060ff83166040830152949350505050565b6000825161441b8184602087016141d3565b9190910192915050565b600082601f83011261443657600080fd5b815161444461369482613752565b81815284602083860101111561445957600080fd5b6132588260208301602087016141d3565b60006020828403121561447c57600080fd5b81516001600160401b038082111561449357600080fd5b90830190604082860312156144a757600080fd5b6144af6135b7565b825181526020830151828111156144c557600080fd5b61383187828601614425565b60018060a01b0385168152836020820152826040820152608060608201526000612f1260808301846141f7565b85815260a06020820152600061451760a08301876141f7565b604083018690526001600160a01b0385166060840152828103608084015261453f81856141f7565b98975050505050505050565b602081526000611aa660208301846143be565b81810381811115610929576109296142e6565b634e487b7160e01b600052603160045260246000fd5b60006020828403121561459957600080fd5b81516001600160401b03808211156145b057600080fd5b9083019060c082860312156145c457600080fd5b6145cc6135d9565b8251815260208301516145de8161364e565b602082015260408301516145f18161364e565b80604083015250606083015160608201526080830151608082015260a08301518281111561461e57600080fd5b61462a87828601614425565b60a08301525095945050505050565b60008261465657634e487b7160e01b600052601260045260246000fd5b500690565b60006020828403121561466d57600080fd5b81518015158114611aa657600080fdfea264697066735822122037c56b5e8a08b2310f1dee49bf828ce85349d402c6084523f0d6afc1cfb247d664736f6c634300081300332152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d

Deployed Bytecode

0x6080604052600436106102555760003560e01c80639b6c7efa11610139578063db58eaec116100b6578063eed88b8d1161007a578063eed88b8d14610840578063efe4b0ae14610860578063f2fde38b14610875578063f62b984314610895578063fc525395146108b5578063fe46a413146108d557600080fd5b8063db58eaec14610790578063e01658d9146107c0578063e02146b8146107e0578063e3a95a5a14610800578063ed68595a1461082057600080fd5b8063a4757b0f116100fd578063a4757b0f14610598578063aa3f85c8146106a6578063c37255f2146106e3578063c4bffe2b14610703578063c71cca161461072557600080fd5b80639b6c7efa146105f65780639d0cb9d414610626578063a25d389214610646578063a2711ff414610666578063a3d5b2551461068657600080fd5b806355c4fed4116101d2578063715018a611610196578063715018a6146105195780637670d1d81461052e57806376e5379a1461054e5780638da5cb5b1461059857806390f7af54146105b6578063917cbb9b146105d657600080fd5b806355c4fed41461041c5780635b9d97c614610451578063635f7c031461047e578063654a812b1461049e5780636e74ebe8146104b357600080fd5b80633805e84e116102195780633805e84e146103415780633eb59f601461038a578063436bd103146103aa578063452a9320146103ca57806350311090146103fc57600080fd5b80630a234b15146102615780630fb9ca41146102835780631947051e146102b957806334987236146102d957806334f7870c1461031457600080fd5b3661025c57005b600080fd5b34801561026d57600080fd5b5061028161027c36600461371e565b6108f5565b005b34801561028f57600080fd5b506102a361029e3660046137ca565b610909565b6040516102b09190613840565b60405180910390f35b3480156102c557600080fd5b506102816102d43660046138f0565b61092f565b3480156102e557600080fd5b506103066102f4366004613924565b60009081526008602052604090205490565b6040519081526020016102b0565b34801561032057600080fd5b5061033461032f366004613924565b610a73565b6040516102b0919061393d565b34801561034d57600080fd5b5061037a61035c366004613999565b6001600160a01b031660009081526004602052604090205460ff1690565b60405190151581526020016102b0565b34801561039657600080fd5b506102816103a5366004613a25565b610afe565b3480156103b657600080fd5b5061037a6103c53660046138f0565b610ebf565b3480156103d657600080fd5b506001546001600160a01b03165b6040516001600160a01b0390911681526020016102b0565b34801561040857600080fd5b50610281610417366004613b10565b610ecd565b34801561042857600080fd5b5061043c610437366004613b44565b610f66565b604080519283526020830191909152016102b0565b34801561045d57600080fd5b5061047161046c366004613924565b61114d565b6040516102b09190613ba6565b34801561048a57600080fd5b50610281610499366004613db0565b61116a565b3480156104aa57600080fd5b50600354610306565b3480156104bf57600080fd5b506102a36104ce366004613924565b6040805180820190915260008082526020820152506000908152603a602090815260409182902082518084019093525460ff8116835261010090046001600160781b03169082015290565b34801561052557600080fd5b50610281611242565b34801561053a57600080fd5b50610281610549366004613ea2565b611256565b34801561055a57600080fd5b5061037a610569366004613ed6565b6000828152603b602090815260408083206001600160a01b038516845260010190915290205460ff1692915050565b3480156105a457600080fd5b506000546001600160a01b03166103e4565b3480156105c257600080fd5b506102816105d1366004613ea2565b611269565b3480156105e257600080fd5b506102816105f1366004613f06565b61127c565b34801561060257600080fd5b5061037a610611366004613924565b60009081526006602052604090205460ff1690565b34801561063257600080fd5b50610281610641366004613f4e565b61128d565b34801561065257600080fd5b50610306610661366004613f82565b6112a0565b34801561067257600080fd5b50610281610681366004613fc6565b6113db565b34801561069257600080fd5b506102816106a1366004614087565b6113ec565b3480156106b257600080fd5b506106d66106c1366004613924565b6000908152603c602052604090205460ff1690565b6040516102b091906140de565b3480156106ef57600080fd5b5061037a6106fe3660046137ca565b6114b2565b34801561070f57600080fd5b506107186114c0565b6040516102b09190614106565b34801561073157600080fd5b506102a3610740366004613924565b6040805180820190915260008082526020820152506040805180820182526000838152603b60208181529382205460ff811684529490915282526101009092046001600160781b03169082015290565b34801561079c57600080fd5b5061037a6107ab366004613924565b60009081526005602052604090205460ff1690565b3480156107cc57600080fd5b506106d66107db3660046138f0565b6114cc565b3480156107ec57600080fd5b506102816107fb366004613b10565b6114da565b34801561080c57600080fd5b5061028161081b366004613f4e565b6114eb565b34801561082c57600080fd5b5061028161083b36600461413e565b6114fe565b34801561084c57600080fd5b5061028161085b366004614173565b6118ce565b34801561086c57600080fd5b50600254610306565b34801561088157600080fd5b50610281610890366004613999565b611a15565b3480156108a157600080fd5b5061037a6108b0366004614173565b611a8b565b3480156108c157600080fd5b506102816108d0366004613999565b611aad565b3480156108e157600080fd5b506102816108f036600461419f565b611abe565b6108fd611acf565b61090681611b29565b50565b604080518082019091526000808252602082015261092961074083611dcd565b92915050565b600061093a82611de4565b905060016000828152603c602052604090205460ff166002811115610961576109616140c8565b1460405180604001604052806002815260200161191960f11b815250906109a45760405162461bcd60e51b815260040161099b9190614223565b60405180910390fd5b506000818152603c6020908152604091829020805460ff191660021790558382015190840151606085015160a08601519351630a81a65d60e11b81526001600160a01b03909316936315034cba93610a0193929190600401614236565b600060405180830381600087803b158015610a1b57600080fd5b505af1158015610a2f573d6000803e3d6000fd5b505050507fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab81836001604051610a67939291906142bb565b60405180910390a15050565b606060076000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610af3576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610aa8565b505050509050919050565b610b06611df0565b8251602084012060009060008181526006602052604090205490915060ff1660405180604001604052806002815260200161313960f01b81525090610b5e5760405162461bcd60e51b815260040161099b9190614223565b506000610b6a85611e5f565b90506000610b7782611e88565b905060006007600083608001518152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610bfd576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101610bb2565b5050505090506000815111604051806040016040528060028152602001610c4d60f21b81525090610c415760405162461bcd60e51b815260040161099b9190614223565b50600085516001600160401b03811115610c5d57610c5d613579565b604051908082528060200260200182016040528015610ca257816020015b6040805180820190915260008082526020820152815260200190600190039081610c7b5790505b50905060005b8651811015610e5a576000610cbe8260016142fc565b90505b8751811015610d5e57878181518110610cdc57610cdc61430f565b60200260200101516001600160a01b0316888381518110610cff57610cff61430f565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161323160f01b81525090610d4b5760405162461bcd60e51b815260040161099b9190614223565b5080610d5681614325565b915050610cc1565b506000805b8451811015610e0d57848181518110610d7e57610d7e61430f565b6020026020010151602001516001600160a01b0316898481518110610da557610da561430f565b60200260200101516001600160a01b031603610dfb57848181518110610dcd57610dcd61430f565b6020026020010151848481518110610de757610de761430f565b602002602001018190525060019150610e0d565b80610e0581614325565b915050610d63565b50604080518082019091526002815261062760f31b602082015281610e455760405162461bcd60e51b815260040161099b9190614223565b50508080610e5290614325565b915050610ca8565b506000610e77610e6986611e9d565b878b87608001518c87611eb0565b90508060405180604001604052806002815260200161032360f41b81525090610eb35760405162461bcd60e51b815260040161099b9190614223565b50505050505050505050565b60006109296107ab83611de4565b607154600390610100900460ff16158015610eef575060715460ff8083169116105b610f0b5760405162461bcd60e51b815260040161099b9061433e565b6071805461ffff191660ff831617610100179055610f288261205a565b6071805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610a67565b33600090815260046020526040812054819060ff16604051806040016040528060018152602001601960f91b81525090610fb35760405162461bcd60e51b815260040161099b9190614223565b506000610fbf8761213e565b90506000815111604051806040016040528060028152602001610c4d60f21b81525090610fff5760405162461bcd60e51b815260040161099b9190614223565b50600280546000918261101183614325565b91905055905060006040518060c00160405280838152602001336001600160a01b03168152602001896001600160a01b031681526020014681526020018a815260200187815250905060006110658261230e565b6020808201805160009081526005909252604091829020805460ff19166001179055519051919250907f18d245f6501b267c6fc4ab6bb6f037c83d28a9ab089e79ab063162d414d2d9c9906110bb90859061438c565b60405180910390a260006110f96040518060400160405280600360008154809291906110e690614325565b909155508152845160209091015261236f565b6020808201805160009081526006835260409020805460ff1916600117905590840151905182516080870151939450611133938d8a611eb0565b50602091820151910151909a909950975050505050505050565b6000818152603a60205260409020606090610929906001016123aa565b607154610100900460ff161580801561118a5750607154600160ff909116105b806111a45750303b1580156111a4575060715460ff166001145b6111c05760405162461bcd60e51b815260040161099b9061433e565b6071805460ff1916600117905580156111e3576071805461ff0019166101001790555b6111f2888888888888886123b7565b8015611238576071805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b61124a611acf565b61125460006124e9565b565b61125e611acf565b610906816000612539565b611271611acf565b610906816001612539565b611284611acf565b61090681612669565b611295611acf565b610906816001612935565b60006112aa611df0565b60006112b58461230e565b90506112d4816020015160009081526005602052604090205460ff1690565b604051806040016040528060018152602001603360f81b8152509061130c5760405162461bcd60e51b815260040161099b9190614223565b50600061131c856080015161213e565b90506000815111604051806040016040528060028152602001610c4d60f21b8152509061135c5760405162461bcd60e51b815260040161099b9190614223565b50600061139360405180604001604052806003600081548092919061138090614325565b909155508152855160209091015261236f565b6020808201805160009081526006835260409020805460ff19166001179055908501519051825160808a01519394506113cd938987611eb0565b506020015195945050505050565b6113e3611acf565b61090681612ba0565b6000546001600160a01b0316331461143d5760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b604482015260640161099b565b6114516001600160a01b0384168383612cc9565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fc7af665d489507e14ae25ac7ab0030fc7f570869610bdd32117ea56b60ae5c61846040516114a091815260200190565b60405180910390a4505050565b905090565b600061092961061183611dcd565b60606114ad603d6123aa565b60006109296106c183611de4565b6114e2611acf565b6109068161205a565b6114f3611acf565b610906816000612935565b806115093382611a8b565b604051806040016040528060018152602001603560f81b815250906115415760405162461bcd60e51b815260040161099b9190614223565b50600061154d84611e5f565b9050600061155a82611e88565b90508381606001511480156115725750468160800151145b60405180604001604052806002815260200161333360f01b815250906115ab5760405162461bcd60e51b815260040161099b9190614223565b5060006115b783611e9d565b865160208801209091506000906000818152603b602090815260408083208a8452603a83529281902081518083019092525460ff811682526001600160781b0361010091829004811693830193909352835494955092939092900416801580611652575033600090815260018401602052604090205460ff16158015611652575081602001516001600160781b0316816001600160781b0316115b15610eb357806001600160781b0316600003611687578254610100600160801b031916610100426001600160781b0316021783555b82546000908490829061169c9060ff1661439f565b825460ff8083166101009490940a93840293021916919091179091553360008181526001878101602052604091829020805460ff1916909117905551919250908b9088907f5353716bf921d1d85f5567a99a718cc63ff1182dca5f9163d9e9b8f1fc3ac38790611711908a908e9088906143dd565b60405180910390a46000868152603c602052604081205460ff16600281111561173c5761173c6140c8565b1461174e575050505050505050505050565b825160ff161580159061176b5750826000015160ff168160ff1610155b156118c0576000868152603c6020908152604091829020805460ff19166002179055888201519089015160608a015160a08b01519351630a81a65d60e11b81526001600160a01b03909316936315034cba936117cc93929190600401614236565b600060405180830381600087803b1580156117e657600080fd5b505af19250505080156117f7575060015b611883573d808015611825576040519150601f19603f3d011682016040523d82523d6000602084013e61182a565b606091505b506000878152603c6020526040808220805460ff19166001179055517fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab91611875918a918c916142bb565b60405180910390a1506118c0565b7fa2540dac02f8d07ec0107c5fc2172e2c49d3231e86a21cb02b47058635ae97ab868860016040516118b7939291906142bb565b60405180910390a15b50505050505050505b505050565b6000546001600160a01b0316331461191f5760405162461bcd60e51b815260206004820152601460248201527327a7262cafa922a9a1aaa2afa3aaa0a92224a0a760611b604482015260640161099b565b604080516000808252602082019092526001600160a01b0384169083906040516119499190614409565b60006040518083038185875af1925050503d8060008114611986576040519150601f19603f3d011682016040523d82523d6000602084013e61198b565b606091505b50509050806119d05760405162461bcd60e51b815260206004820152601160248201527011551217d514905394d1915497d1905253607a1b604482015260640161099b565b6040518281526001600160a01b0384169033907fb7c602059992183c7b767c08204223afc99f1895fd175adf9ece23ce9f5bb8b79060200160405180910390a3505050565b611a1d611acf565b6001600160a01b038116611a825760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161099b565b610906816124e9565b6000818152603a60205260408120611aa69060010184612d1b565b9392505050565b611ab5611df0565b61090681612d3d565b611ac6611acf565b61090681612d97565b6000546001600160a01b031633146112545760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161099b565b60005b8151811015611dc9576000828281518110611b4957611b4961430f565b6020026020010151905060006001600160a01b031681602001516001600160a01b031614158015611b83575080516001600160a01b031615155b604051806040016040528060018152602001600d60fa1b81525090611bbb5760405162461bcd60e51b815260040161099b9190614223565b506040808201516000908152600760205290812090805b8254811015611cb5576000838281548110611bef57611bef61430f565b60009182526020909120865160029092020160018101549092506001600160a01b03918216911603611ca257602085015181546001600160a01b03908116911614611c985760208581015182546001600160a01b0319166001600160a01b03918216908117845587516040808a015190519283526001949190931692917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b6001925050611cb5565b5080611cad81614325565b915050611bd2565b5080611db35782516040805160048152602481018252602080820180516001600160e01b03166352d1043d60e01b17905282518084019093526002835261199960f11b90830152611d069291612ea4565b50604080518082018252602085810180516001600160a01b03908116845287518116838501908152875460018082018a5560008a81528690209651600290920290960180549184166001600160a01b03199283161781559151918601805492841692909116919091179055875188860151925195519582168652939493169290917f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d910160405180910390a45b5050508080611dc190614325565b915050611b2c565b5050565b600080611dd98361236f565b602001519392505050565b600080611dd98361230e565b6000546001600160a01b0316331480611e1357506001546001600160a01b031633145b6112545760405162461bcd60e51b815260206004820152601960248201527f4f4e4c595f42595f4f574e45525f4f525f475541524449414e00000000000000604482015260640161099b565b60408051808201909152600081526060602082015281806020019051810190610929919061446a565b611e90613531565b6109298260200151612f1c565b6020808201518051910120600090610929565b600080805b835181101561204e57600080858381518110611ed357611ed361430f565b6020026020010151602001516001600160a01b03166336da7a0660e01b878581518110611f0257611f0261430f565b602002602001015160000151898b8d604051602401611f2494939291906144d1565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611f629190614409565b600060405180830381855af49150503d8060008114611f9d576040519150601f19603f3d011682016040523d82523d6000602084013e611fa2565b606091505b50915091508115611fb257600193505b811515868481518110611fc757611fc761430f565b6020026020010151602001516001600160a01b03168c7f935aa87d643578e6395c90fdbd5d50ffee5f2c1f6ce2cd01274740412bb679f48d8d8d8c8a815181106120135761201361430f565b602002602001015160000151886040516120319594939291906144fe565b60405180910390a45050808061204690614325565b915050611eb5565b50979650505050505050565b60005b8151811015611dc9578181815181106120785761207861430f565b6020026020010151602001516008600084848151811061209a5761209a61430f565b6020026020010151600001518152602001908152602001600020819055508181815181106120ca576120ca61430f565b6020026020010151600001517fa7db3ff5dbb4e968ca876b88c9cc737050842adf8bbeef18db5a8a18391cd7098383815181106121095761210961430f565b60200260200101516020015160405161212491815260200190565b60405180910390a28061213681614325565b91505061205d565b60008181526008602090815260408083205460079092529091206060919081158061216a575080548210155b156121e85780805480602002602001604051908101604052809291908181526020016000905b828210156121db576000848152602090819020604080518082019091526002850290910180546001600160a01b03908116835260019182015416828401529083529092019101612190565b5050505092505050919050565b60006122006121fa8380549050612f38565b84612fc2565b90506000836001600160401b0381111561221c5761221c613579565b60405190808252806020026020018201604052801561226157816020015b604080518082019091526000808252602082015281526020019060019003908161223a5790505b50905060005b8481101561230457838382815181106122825761228261430f565b60200260200101518154811061229a5761229a61430f565b60009182526020918290206040805180820190915260029092020180546001600160a01b039081168352600190910154169181019190915282518390839081106122e6576122e661430f565b602002602001018190525080806122fc90614325565b915050612267565b5095945050505050565b60408051808201909152606081526000602082015260408051808201909152606081526000602082015282604051602001612349919061438c565b60408051808303601f190181529190528082528051602090910120602082015292915050565b60408051808201909152606081526000602082015260408051808201909152606081526000602082015282604051602001612349919061454b565b60606000611aa68361307d565b607154610100900460ff16158080156123d75750607154600160ff909116105b806123f15750303b1580156123f1575060715460ff166001145b61240d5760405162461bcd60e51b815260040161099b9061433e565b6071805460ff191660011790558015612430576071805461ff0019166101001790555b612439886124e9565b61244287612d3d565b6040805160008082526020820190925261248d91879190612486565b60408051808201909152600081526060602082015281526020019060019003908161245e5790505b50886130d9565b604080516000808252602082019092526111f2918691906124d1565b6040805180820190915260008152606060208201528152602001906001900390816124a95790505b506040805160008152602081019091528690866130f8565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005b82518110156118c95760006001600160a01b03168382815181106125625761256261430f565b60200260200101516001600160a01b0316141560405180604001604052806002815260200161199b60f11b815250906125ae5760405162461bcd60e51b815260040161099b9190614223565b5081600460008584815181106125c6576125c661430f565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555081151583828151811061261a5761261a61430f565b60200260200101516001600160a01b03167f626c27c1d088fd70034e681d579a5efd004c3d47a56d3ee07ad256ac7301433360405160405180910390a38061266181614325565b91505061253c565b60005b8151811015611dc95760005b82828151811061268a5761268a61430f565b60200260200101516020015151811015612922576000600760008585815181106126b6576126b661430f565b60200260200101516020015184815181106126d3576126d361430f565b60200260200101518152602001908152602001600020905060005b815481101561290d578484815181106127095761270961430f565b6020026020010151600001516001600160a01b03168282815481106127305761273061430f565b60009182526020909120600160029092020101546001600160a01b0316036128fb5760008282815481106127665761276661430f565b600091825260209091206002909102015483546001600160a01b03909116915083906127949060019061455e565b815481106127a4576127a461430f565b90600052602060002090600202018383815481106127c4576127c461430f565b60009182526020909120825460029092020180546001600160a01b039283166001600160a01b0319918216178255600193840154939091018054939092169216919091179055825483908061281b5761281b614571565b60008281526020812060026000199093019283020180546001600160a01b0319908116825560019190910180549091169055915586518790879081106128635761286361430f565b6020026020010151600001516001600160a01b031687878151811061288a5761288a61430f565b60200260200101516020015186815181106128a7576128a761430f565b60200260200101517f2152376b51b154ef9693e64efbda43bd7ecd04ccb98df7f6caf781078eca308d846040516128ed91906001600160a01b0391909116815260200190565b60405180910390a45061290d565b8061290581614325565b9150506126ee565b5050808061291a90614325565b915050612678565b508061292d81614325565b91505061266c565b60005b82518110156118c95760008382815181106129555761295561430f565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316141560405180604001604052806002815260200161062760f31b815250906129b35760405162461bcd60e51b815260040161099b9190614223565b5060005b816020015151811015612b8b5760008415612a4e576129fd836020015183815181106129e5576129e561430f565b6020026020010151603d61313090919063ffffffff16565b50612a478360000151603a600086602001518681518110612a2057612a2061430f565b6020026020010151815260200190815260200160002060010161313c90919063ffffffff16565b9050612b16565b612a978360000151603a600086602001518681518110612a7057612a7061430f565b6020026020010151815260200190815260200160002060010161315190919063ffffffff16565b9050808015612ade5750612adc603a600085602001518581518110612abe57612abe61430f565b60200260200101518152602001908152602001600020600101613166565b155b15612b1657612b1483602001518381518110612afc57612afc61430f565b6020026020010151603d61317090919063ffffffff16565b505b8015612b785782602001518281518110612b3257612b3261430f565b602002602001015185151584600001516001600160a01b03167f537ae69afd3600f30d8c662539017cc022c73b04db804445c9eaae801c2f4a8360405160405180910390a45b5080612b8381614325565b9150506129b7565b50508080612b9890614325565b915050612938565b60005b8151811015611dc9576000828281518110612bc057612bc061430f565b60209081029190910181015180516000908152603a83526040902054918101519092506001600160781b0361010090920482169116118015612c0f57504281602001516001600160781b031611155b604051806040016040528060018152602001601b60f91b81525090612c475760405162461bcd60e51b815260040161099b9190614223565b506020818101805183516000908152603a84526040908190208054610100600160801b0319166101006001600160781b03948516021790558451925190519116815290917f79b1ca301c237cd649b2d35eb6f0873650079b8bb613a17279bbf80332754ddd910160405180910390a25080612cc181614325565b915050612ba3565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526118c990849061317c565b6001600160a01b03811660009081526001830160205260408120541515611aa6565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad9099101610a67565b60005b8151811015611dc9576000828281518110612db757612db761430f565b602002602001015190506000816020015160ff16118015612dfa575080516000908152603a60205260409020612def90600101613166565b816020015160ff1611155b60405180604001604052806002815260200161189b60f11b81525090612e335760405162461bcd60e51b815260040161099b9190614223565b506020818101805183516000908152603a8452604090819020805460ff191660ff9384161790558451925190519116815290917f799ef5c83e710778f5725ab120f43a73d21b1d98f2e1a058801728ace31275fd910160405180910390a25080612e9c81614325565b915050612d9a565b6060600080856001600160a01b031685604051612ec19190614409565b600060405180830381855af49150503d8060008114612efc576040519150601f19603f3d011682016040523d82523d6000602084013e612f01565b606091505b5091509150612f12868383876131df565b9695505050505050565b612f24613531565b818060200190518101906109299190614587565b60606000826001600160401b03811115612f5457612f54613579565b604051908082528060200260200182016040528015612f7d578160200160208202803683370190505b50905060005b83811015612fbb5780828281518110612f9e57612f9e61430f565b602090810291909101015280612fb381614325565b915050612f83565b5092915050565b815160609060005b8381101561307457600082612fde83613260565b612fe89190614639565b90506000868381518110612ffe57612ffe61430f565b6020026020010151905086828151811061301a5761301a61430f565b60200260200101518784815181106130345761303461430f565b602002602001018181525050808783815181106130535761305361430f565b6020026020010181815250505050808061306c90614325565b915050612fca565b50929392505050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156130cd57602002820191906000526020600020905b8154815260200190600101908083116130b9575b50505050509050919050565b6130e4836001612935565b6130ef826000612935565b6118c981612d97565b61310185611b29565b61310a84612669565b613115836001612539565b613120826000612539565b6131298161205a565b5050505050565b6000611aa683836132a6565b6000611aa6836001600160a01b0384166132a6565b6000611aa6836001600160a01b0384166132f5565b6000610929825490565b6000611aa683836132f5565b60006131916001600160a01b038416836133e8565b905080516000141580156131b65750808060200190518101906131b4919061465b565b155b156118c957604051635274afe760e01b81526001600160a01b038416600482015260240161099b565b6060831561324e578251600003613247576001600160a01b0385163b6132475760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161099b565b5081613258565b613258838361342c565b949350505050565b60008061326e60014361455e565b604080516020808201849052924081830152606080820196909652815180820390960186526080019052835193019290922092915050565b60008181526001830160205260408120546132ed57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610929565b506000610929565b600081815260018301602052604081205480156133de57600061331960018361455e565b855490915060009061332d9060019061455e565b905081811461339257600086600001828154811061334d5761334d61430f565b90600052602060002001549050808760000184815481106133705761337061430f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806133a3576133a3614571565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610929565b6000915050610929565b6060611aa6838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250613456565b81511561343c5781518083602001fd5b8060405162461bcd60e51b815260040161099b9190614223565b6060824710156134b75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161099b565b600080866001600160a01b031685876040516134d39190614409565b60006040518083038185875af1925050503d8060008114613510576040519150601f19603f3d011682016040523d82523d6000602084013e613515565b606091505b5091509150613526878383876131df565b979650505050505050565b6040518060c001604052806000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156135b1576135b1613579565b60405290565b604080519081016001600160401b03811182821017156135b1576135b1613579565b60405160c081016001600160401b03811182821017156135b1576135b1613579565b604051601f8201601f191681016001600160401b038111828210171561362357613623613579565b604052919050565b60006001600160401b0382111561364457613644613579565b5060051b60200190565b6001600160a01b038116811461090657600080fd5b803561366e8161364e565b919050565b600082601f83011261368457600080fd5b813560206136996136948361362b565b6135fb565b828152606092830285018201928282019190878511156136b857600080fd5b8387015b858110156137115781818a0312156136d45760008081fd5b6136dc61358f565b81356136e78161364e565b8152818601356136f68161364e565b818701526040828101359082015284529284019281016136bc565b5090979650505050505050565b60006020828403121561373057600080fd5b81356001600160401b0381111561374657600080fd5b61325884828501613673565b60006001600160401b0382111561376b5761376b613579565b50601f01601f191660200190565b600082601f83011261378a57600080fd5b813561379861369482613752565b8181528460208386010111156137ad57600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156137dc57600080fd5b81356001600160401b03808211156137f357600080fd5b908301906040828603121561380757600080fd5b61380f6135b7565b8235815260208301358281111561382557600080fd5b61383187828601613779565b60208301525095945050505050565b815160ff1681526020808301516001600160781b03169082015260408101610929565b600060c0828403121561387557600080fd5b61387d6135d9565b90508135815260208201356138918161364e565b602082015260408201356138a48161364e565b80604083015250606082013560608201526080820135608082015260a08201356001600160401b038111156138d857600080fd5b6138e484828501613779565b60a08301525092915050565b60006020828403121561390257600080fd5b81356001600160401b0381111561391857600080fd5b61325884828501613863565b60006020828403121561393657600080fd5b5035919050565b602080825282518282018190526000919060409081850190868401855b8281101561398c57815180516001600160a01b039081168652908701511686850152928401929085019060010161395a565b5091979650505050505050565b6000602082840312156139ab57600080fd5b8135611aa68161364e565b600082601f8301126139c757600080fd5b813560206139d76136948361362b565b82815260059290921b840181019181810190868411156139f657600080fd5b8286015b84811015613a1a578035613a0d8161364e565b83529183019183016139fa565b509695505050505050565b600080600060608486031215613a3a57600080fd5b83356001600160401b0380821115613a5157600080fd5b613a5d87838801613779565b9450602086013593506040860135915080821115613a7a57600080fd5b50613a87868287016139b6565b9150509250925092565b600082601f830112613aa257600080fd5b81356020613ab26136948361362b565b82815260069290921b84018101918181019086841115613ad157600080fd5b8286015b84811015613a1a5760408189031215613aee5760008081fd5b613af66135b7565b813581528482013585820152835291830191604001613ad5565b600060208284031215613b2257600080fd5b81356001600160401b03811115613b3857600080fd5b61325884828501613a91565b60008060008060808587031215613b5a57600080fd5b843593506020850135613b6c8161364e565b92506040850135915060608501356001600160401b03811115613b8e57600080fd5b613b9a87828801613779565b91505092959194509250565b6020808252825182820181905260009190848201906040850190845b81811015613be75783516001600160a01b031683529284019291840191600101613bc2565b50909695505050505050565b600082601f830112613c0457600080fd5b81356020613c146136948361362b565b82815260069290921b84018101918181019086841115613c3357600080fd5b8286015b84811015613a1a5760408189031215613c505760008081fd5b613c586135b7565b813581528482013560ff81168114613c705760008081fd5b81860152835291830191604001613c37565b6000613c906136948461362b565b8381529050602080820190600585811b850187811115613caf57600080fd5b855b81811015613d845780356001600160401b0380821115613cd15760008081fd5b908801906040828c031215613ce65760008081fd5b613cee6135b7565b8235613cf98161364e565b81528287013582811115613d0d5760008081fd5b8084019350508b601f840112613d2557600091508182fd5b82359150613d356136948361362b565b82815291861b8301870191878101908d841115613d525760008081fd5b938801935b83851015613d7057843582529388019390880190613d57565b828901525087525050938301938301613cb1565b50505050509392505050565b600082601f830112613da157600080fd5b611aa683833560208501613c82565b600080600080600080600060e0888a031215613dcb57600080fd5b613dd488613663565b9650613de260208901613663565b955060408801356001600160401b0380821115613dfe57600080fd5b613e0a8b838c01613bf3565b965060608a0135915080821115613e2057600080fd5b613e2c8b838c01613d90565b955060808a0135915080821115613e4257600080fd5b613e4e8b838c01613673565b945060a08a0135915080821115613e6457600080fd5b613e708b838c016139b6565b935060c08a0135915080821115613e8657600080fd5b50613e938a828b01613a91565b91505092959891949750929550565b600060208284031215613eb457600080fd5b81356001600160401b03811115613eca57600080fd5b613258848285016139b6565b60008060408385031215613ee957600080fd5b823591506020830135613efb8161364e565b809150509250929050565b600060208284031215613f1857600080fd5b81356001600160401b03811115613f2e57600080fd5b8201601f81018413613f3f57600080fd5b61325884823560208401613c82565b600060208284031215613f6057600080fd5b81356001600160401b03811115613f7657600080fd5b61325884828501613d90565b60008060408385031215613f9557600080fd5b82356001600160401b03811115613fab57600080fd5b613fb785828601613863565b95602094909401359450505050565b60006020808385031215613fd957600080fd5b82356001600160401b03811115613fef57600080fd5b8301601f8101851361400057600080fd5b803561400e6136948261362b565b81815260069190911b8201830190838101908783111561402d57600080fd5b928401925b82841015613526576040848903121561404b5760008081fd5b6140536135b7565b84358152858501356001600160781b03811681146140715760008081fd5b8187015282526040939093019290840190614032565b60008060006060848603121561409c57600080fd5b83356140a78161364e565b925060208401356140b78161364e565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b602081016003831061410057634e487b7160e01b600052602160045260246000fd5b91905290565b6020808252825182820181905260009190848201906040850190845b81811015613be757835183529284019291840191600101614122565b6000806040838503121561415157600080fd5b82356001600160401b0381111561416757600080fd5b613fb785828601613779565b6000806040838503121561418657600080fd5b82356141918161364e565b946020939093013593505050565b6000602082840312156141b157600080fd5b81356001600160401b038111156141c757600080fd5b61325884828501613bf3565b60005b838110156141ee5781810151838201526020016141d6565b50506000910152565b6000815180845261420f8160208601602086016141d3565b601f01601f19169290920160200192915050565b602081526000611aa660208301846141f7565b60018060a01b038416815282602082015260606040820152600061425d60608301846141f7565b95945050505050565b805182526000602082015160018060a01b0380821660208601528060408501511660408601525050606082015160608401526080820151608084015260a082015160c060a085015261325860c08501826141f7565b8381526060602082015260006142d46060830185614266565b90508215156040830152949350505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610929576109296142e6565b634e487b7160e01b600052603260045260246000fd5b600060018201614337576143376142e6565b5060010190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602081526000611aa66020830184614266565b600060ff821660ff81036143b5576143b56142e6565b60010192915050565b80518252600060208201516040602085015261325860408501826141f7565b8381526060602082015260006143f660608301856143be565b905060ff83166040830152949350505050565b6000825161441b8184602087016141d3565b9190910192915050565b600082601f83011261443657600080fd5b815161444461369482613752565b81815284602083860101111561445957600080fd5b6132588260208301602087016141d3565b60006020828403121561447c57600080fd5b81516001600160401b038082111561449357600080fd5b90830190604082860312156144a757600080fd5b6144af6135b7565b825181526020830151828111156144c557600080fd5b61383187828601614425565b60018060a01b0385168152836020820152826040820152608060608201526000612f1260808301846141f7565b85815260a06020820152600061451760a08301876141f7565b604083018690526001600160a01b0385166060840152828103608084015261453f81856141f7565b98975050505050505050565b602081526000611aa660208301846143be565b81810381811115610929576109296142e6565b634e487b7160e01b600052603160045260246000fd5b60006020828403121561459957600080fd5b81516001600160401b03808211156145b057600080fd5b9083019060c082860312156145c457600080fd5b6145cc6135d9565b8251815260208301516145de8161364e565b602082015260408301516145f18161364e565b80604083015250606083015160608201526080830151608082015260a08301518281111561461e57600080fd5b61462a87828601614425565b60a08301525095945050505050565b60008261465657634e487b7160e01b600052601260045260246000fd5b500690565b60006020828403121561466d57600080fd5b81518015158114611aa657600080fdfea264697066735822122037c56b5e8a08b2310f1dee49bf828ce85349d402c6084523f0d6afc1cfb247d664736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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