-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added linea adapter deploy scripts
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import './BaseAdapterScript.sol'; | ||
import {LineaAdapter, ILineaAdapter} from '../../src/contracts/adapters/linea/LineaAdapter.sol'; | ||
import {LineaAdapterTestnet} from '../contract_extensions/LineaAdapter.sol'; | ||
|
||
library LineaAdapterDeploymentHelper { | ||
struct LineaAdapterArgs { | ||
BaseAdapterArgs baseArgs; | ||
address lineaMessageService; | ||
} | ||
|
||
function getAdapterCode(LineaAdapterArgs memory lineaArgs) internal pure returns (bytes memory) { | ||
bytes memory creationCode = lineaArgs.baseArgs.isTestnet | ||
? type(LineaAdapterTestnet).creationCode | ||
: type(LineaAdapter).creationCode; | ||
|
||
return | ||
abi.encodePacked( | ||
creationCode, | ||
abi.encode( | ||
lineaArgs.baseArgs.crossChainController, | ||
lineaArgs.lineaMessageService, | ||
lineaArgs.baseArgs.providerGasLimit, | ||
lineaArgs.baseArgs.trustedRemotes | ||
) | ||
); | ||
} | ||
} | ||
|
||
abstract contract BaseDeployLineaAdapter is BaseAdapterScript { | ||
function LINEA_MESSAGE_SERVICE() internal view virtual returns (address) { | ||
return address(0); | ||
} | ||
|
||
function PROVIDER_GAS_LIMIT() internal view virtual override returns (uint256) { | ||
return 150_000; | ||
} | ||
|
||
function _getAdapterByteCode( | ||
BaseAdapterArgs memory baseArgs | ||
) internal view override returns (bytes memory) { | ||
require(baseArgs.trustedRemotes.length == 1, 'Linea adapter can only have one remote'); | ||
require(LINEA_MESSAGE_SERVICE() != address(0), 'Linea message service can not be 0'); | ||
|
||
return | ||
LineaAdapterDeploymentHelper.getAdapterCode( | ||
LineaAdapterDeploymentHelper.LineaAdapterArgs({ | ||
baseArgs: baseArgs, | ||
inbox: LINEA_MESSAGE_SERVICE() | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.8; | ||
|
||
import {TestNetChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; | ||
import {ILineaAdapter, LineaAdapter} from '../../src/contracts/adapters/linea/LineaAdapter.sol'; | ||
|
||
/** | ||
* @title LineaAdapterTestnet | ||
* @author BGD Labs | ||
*/ | ||
contract LineaAdapterTestnet is LineaAdapter { | ||
/** | ||
* @param crossChainController address of the cross chain controller that will use this bridge adapter | ||
* @param lineaMessageService linea entry point address | ||
* @param trustedRemotes list of remote configurations to set as trusted | ||
*/ | ||
constructor( | ||
address crossChainController, | ||
address lineaMessageService, | ||
uint256 providerGasLimit, | ||
TrustedRemotesConfig[] memory trustedRemotes | ||
) | ||
LineaAdapter( | ||
crossChainController, | ||
lineaMessageService, | ||
providerGasLimit, | ||
trustedRemotes, | ||
'Linea native adapter' | ||
) | ||
{} | ||
|
||
/// @inheritdoc ILineaAdapter | ||
function isDestinationChainIdSupported(uint256 chainId) public pure override returns (bool) { | ||
return chainId == TestNetChainIds.LINEA_SEPOLIA; | ||
} | ||
|
||
/// @inheritdoc ILineaAdapter | ||
function getOriginChainId() public pure override returns (uint256) { | ||
return TestNetChainIds.ETHEREUM_SEPOLIA; | ||
} | ||
} |