|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +import {BaseAdapter, IBaseAdapter} from '../BaseAdapter.sol'; |
| 5 | +import {Errors} from '../../libs/Errors.sol'; |
| 6 | +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; |
| 7 | +import {OpAdapter, IOpAdapter} from '../optimism/OpAdapter.sol'; |
| 8 | + |
| 9 | +/** |
| 10 | + * @param crossChainController address of the cross chain controller that will use this bridge adapter |
| 11 | + * @param ovmCrossDomainMessenger XLayer entry point address |
| 12 | + * @param providerGasLimit base gas limit used by the bridge adapter |
| 13 | + * @param trustedRemotes list of remote configurations to set as trusted |
| 14 | + */ |
| 15 | +struct XLayerAdapterArgs { |
| 16 | + address crossChainController; |
| 17 | + address ovmCrossDomainMessenger; |
| 18 | + uint256 providerGasLimit; |
| 19 | + IBaseAdapter.TrustedRemotesConfig[] trustedRemotes; |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * @title XLayerAdapter |
| 24 | + * @author BGD Labs |
| 25 | + * @notice XLayer bridge adapter. Used to send and receive messages cross chain between Ethereum and XLayer |
| 26 | + * @dev it uses the eth balance of CrossChainController contract to pay for message bridging as the method to bridge |
| 27 | + is called via delegate call |
| 28 | + * @dev note that this adapter can only be used for the communication path ETHEREUM -> XLAYER |
| 29 | + * @dev note that this adapter inherits from Optimism adapter and overrides only supported chain |
| 30 | + */ |
| 31 | +contract XLayerAdapter is OpAdapter { |
| 32 | + /** |
| 33 | + * @param args XLayerAdapterArgs necessary to initialize the adapter |
| 34 | + */ |
| 35 | + constructor( |
| 36 | + XLayerAdapterArgs memory args |
| 37 | + ) |
| 38 | + OpAdapter( |
| 39 | + args.crossChainController, |
| 40 | + args.ovmCrossDomainMessenger, |
| 41 | + args.providerGasLimit, |
| 42 | + 'XLayer native adapter', |
| 43 | + args.trustedRemotes |
| 44 | + ) |
| 45 | + {} |
| 46 | + |
| 47 | + /// @inheritdoc IOpAdapter |
| 48 | + function isDestinationChainIdSupported( |
| 49 | + uint256 chainId |
| 50 | + ) public view virtual override returns (bool) { |
| 51 | + return chainId == ChainIds.XLAYER; |
| 52 | + } |
| 53 | + |
| 54 | + /// @inheritdoc IOpAdapter |
| 55 | + function getOriginChainId() public pure virtual override returns (uint256) { |
| 56 | + return ChainIds.ETHEREUM; |
| 57 | + } |
| 58 | +} |
0 commit comments