generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from bgd-labs/feat/aip-activate-linea
feat: Add linea activation path payload
- Loading branch information
Showing
10 changed files
with
170 additions
and
6 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
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
14 changes: 14 additions & 0 deletions
14
...add_linea_path_to_adiethereum_before_adi_add_linea_path_to_adiethereum_after.md
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,14 @@ | ||
## Raw diff | ||
|
||
```json | ||
{ | ||
"forwarderAdaptersByChain": { | ||
"59144": { | ||
"from": "", | ||
"to": { | ||
"0x8097555ffDa4176C93FEf92dF473b9763e467686": "0xB3332d31ECFC3ef3BF6Cda79833D11d1A53f5cE6" | ||
} | ||
} | ||
} | ||
} | ||
``` |
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
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
34 changes: 34 additions & 0 deletions
34
scripts/payloads/adapters/ethereum/Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol
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,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 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 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
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
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,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', 21386891) | ||
{ | ||
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); | ||
} | ||
} |