CrossChainEnabledOptimism.sol 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.4;
  3. import "../CrossChainEnabled.sol";
  4. import "./LibOptimism.sol";
  5. /**
  6. * @dev [Optimism](https://www.optimism.io/) specialization or the
  7. * {CrossChainEnabled} abstraction.
  8. *
  9. * The messenger (`CrossDomainMessenger`) contract is provided and maintained by
  10. * the optimism team. You can find the address of this contract on mainnet and
  11. * kovan in the [deployments section of Optimism monorepo](https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments).
  12. *
  13. * _Available since v4.6._
  14. */
  15. abstract contract CrossChainEnabledOptimism is CrossChainEnabled {
  16. /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
  17. address private immutable _messenger;
  18. /// @custom:oz-upgrades-unsafe-allow constructor
  19. constructor(address messenger) {
  20. _messenger = messenger;
  21. }
  22. /**
  23. * @dev see {CrossChainEnabled-_isCrossChain}
  24. */
  25. function _isCrossChain() internal view virtual override returns (bool) {
  26. return LibOptimism.isCrossChain(_messenger);
  27. }
  28. /**
  29. * @dev see {CrossChainEnabled-_crossChainSender}
  30. */
  31. function _crossChainSender() internal view virtual override onlyCrossChain returns (address) {
  32. return LibOptimism.crossChainSender(_messenger);
  33. }
  34. }