CrossChainEnabledOptimism.sol 1.4 KB

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