generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add linea activation path payload #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
5 changes: 5 additions & 0 deletions
5
...add_linea_path_to_adiethereum_before_adi_add_linea_path_to_adiethereum_after.md
This file contains hidden or 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,5 @@ | ||
| ## Raw diff | ||
|
|
||
| ```json | ||
| {} | ||
| ``` |
34 changes: 34 additions & 0 deletions
34
scripts/payloads/adapters/ethereum/Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol
This file contains hidden or 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,34 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import '../../../BaseDeployerScript.sol'; | ||
| import '../../../../src/templates/SimpleAddForwarderAdapter.sol'; | ||
|
|
||
| abstract contract Ethereum_Activate_Lina_Bridge_Adapter_Payload is BaseDeployerScript { | ||
| function _getPayloadByteCode() internal virtual returns (bytes memory); | ||
|
|
||
| function PAYLOAD_SALT() internal pure virtual returns (string memory) { | ||
| return 'Add Linea path to a.DI'; | ||
| } | ||
|
|
||
| function DESTINATION_CHAIN_ID() internal pure virtual returns (uint256); | ||
|
|
||
| function _deployPayload(AddForwarderAdapterArgs memory args) internal returns (address) { | ||
| bytes memory payloadCode = abi.encodePacked(_getPayloadByteCode(), abi.encode(args)); | ||
|
|
||
| return _deployByteCode(payloadCode, PAYLOAD_SALT()); | ||
| } | ||
|
|
||
| function _execute(Addresses memory addresses) internal virtual override { | ||
| Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID()); | ||
|
|
||
| _deployPayload( | ||
| AddForwarderAdapterArgs({ | ||
| crossChainController: addresses.crossChainController, | ||
| currentChainBridgeAdapter: addresses.lineaAdapter, | ||
| destinationChainBridgeAdapter: destinationAddresses.lineaAdapter, | ||
| destinationChainId: DESTINATION_CHAIN_ID() | ||
| }) | ||
| ); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
scripts/payloads/adapters/ethereum/Network_Deployments.s.sol
This file contains hidden or 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,18 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import './Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol'; | ||
|
|
||
| contract Ethereum is Ethereum_Activate_Lina_Bridge_Adapter_Payload { | ||
| function TRANSACTION_NETWORK() internal pure override returns (uint256) { | ||
| return ChainIds.ETHEREUM; | ||
| } | ||
|
|
||
| function _getPayloadByteCode() internal pure override returns (bytes memory) { | ||
| return type(SimpleAddForwarderAdapter).creationCode; | ||
| } | ||
|
|
||
| function DESTINATION_CHAIN_ID() internal pure override returns (uint256) { | ||
| return ChainIds.LINEA; | ||
| } | ||
| } |
This file contains hidden or 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,92 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import 'forge-std/console.sol'; | ||
| import {ADITestBase} from '../../adi/ADITestBase.sol'; | ||
| import {Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol'; | ||
| import '../../../src/templates/SimpleAddForwarderAdapter.sol'; | ||
|
|
||
| abstract contract BaseAddLineaPathPayloadTest is ADITestBase { | ||
| address internal _payload; | ||
| address internal _crossChainController; | ||
|
|
||
| string internal NETWORK; | ||
| uint256 internal immutable BLOCK_NUMBER; | ||
|
|
||
| constructor(string memory network, uint256 blockNumber) { | ||
| NETWORK = network; | ||
| BLOCK_NUMBER = blockNumber; | ||
| } | ||
|
|
||
| function _getDeployedPayload() internal virtual returns (address); | ||
|
|
||
| function _getPayload() internal virtual returns (address); | ||
|
|
||
| function _getCurrentNetworkAddresses() internal virtual returns (Addresses memory); | ||
|
|
||
| function setUp() public { | ||
| vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER); | ||
|
|
||
| Addresses memory addresses = _getCurrentNetworkAddresses(); | ||
| _crossChainController = addresses.crossChainController; | ||
|
|
||
| _payload = _getPayload(); | ||
| } | ||
|
|
||
| function test_defaultTest() public { | ||
| defaultTest( | ||
| string.concat('add_linea_path_to_adi', NETWORK), | ||
| _crossChainController, | ||
| address(_payload), | ||
| false, | ||
| vm | ||
| ); | ||
| } | ||
|
|
||
| function test_samePayloadAddress( | ||
| address currentChainAdapter, | ||
| address destinationChainAdapter, | ||
| address crossChainController, | ||
| uint256 destinationChainId | ||
| ) public { | ||
| SimpleAddForwarderAdapter deployedPayload = SimpleAddForwarderAdapter(_getDeployedPayload()); | ||
| SimpleAddForwarderAdapter predictedPayload = SimpleAddForwarderAdapter(_getPayload()); | ||
|
|
||
| assertEq(predictedPayload.DESTINATION_CHAIN_ID(), deployedPayload.DESTINATION_CHAIN_ID()); | ||
| assertEq(predictedPayload.CROSS_CHAIN_CONTROLLER(), deployedPayload.CROSS_CHAIN_CONTROLLER()); | ||
| assertEq( | ||
| predictedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER(), | ||
| deployedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER() | ||
| ); | ||
| assertEq( | ||
| predictedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER(), | ||
| deployedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER() | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| contract EthereumAddLineaPathPayloadTest is | ||
| PayloadEthereumScript, | ||
| BaseAddLineaPathPayloadTest('ethereum', 21386314) | ||
| { | ||
| function _getDeployedPayload() internal pure override returns (address) { | ||
| return 0x3C2A076cD5ECbed55D8Fc0A341c14Fc808bA7fF7; | ||
| } | ||
|
|
||
| function _getCurrentNetworkAddresses() internal view override returns (Addresses memory) { | ||
| return _getAddresses(TRANSACTION_NETWORK()); | ||
| } | ||
|
|
||
| function _getPayload() internal override returns (address) { | ||
| Addresses memory currentAddresses = _getCurrentNetworkAddresses(); | ||
| Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID()); | ||
|
|
||
| AddForwarderAdapterArgs memory args = AddForwarderAdapterArgs({ | ||
| crossChainController: currentAddresses.crossChainController, | ||
| currentChainBridgeAdapter: 0x8097555ffDa4176C93FEf92dF473b9763e467686, // ethereum -> linea bridge adapter | ||
| destinationChainBridgeAdapter: 0xB3332d31ECFC3ef3BF6Cda79833D11d1A53f5cE6, // linea bridge adapter | ||
| destinationChainId: DESTINATION_CHAIN_ID() | ||
| }); | ||
| return _deployPayload(args); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.