Skip to content

Commit

Permalink
fix: added linea adapter deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sendra committed Dec 9, 2024
1 parent 3afb7f9 commit 5ef84a0
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
55 changes: 55 additions & 0 deletions scripts/Adapters/DeployLineaAdapter.sol
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()
})
);
}
}
41 changes: 41 additions & 0 deletions scripts/contract_extensions/LineaAdapter.sol
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;
}
}

0 comments on commit 5ef84a0

Please sign in to comment.