generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Ink path activation payload #50
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 2 commits
Commits
Show all changes
3 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
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
14 changes: 14 additions & 0 deletions
14
...adi_add_ink_path_to_adiethereum_before_adi_add_ink_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,14 @@ | ||
| ## Raw diff | ||
|
|
||
| ```json | ||
| { | ||
| "forwarderAdaptersByChain": { | ||
| "57073": { | ||
| "from": "", | ||
| "to": { | ||
| "0x98E78C2cD3013BF13a658E210e27C3732c8Dc48A": "0xC2cD4F76B7a77AEaE3C04A9B6B105EC1Ad28e984" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` |
34 changes: 34 additions & 0 deletions
34
scripts/payloads/adapters/ethereum/Ethereum_Activate_Ink_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_Ink_Bridge_Adapter_Payload is BaseDeployerScript { | ||
| function _getPayloadByteCode() internal virtual returns (bytes memory); | ||
|
|
||
| function PAYLOAD_SALT() internal pure virtual returns (string memory) { | ||
| return 'Add Ink 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.inkAdapter, | ||
| destinationChainBridgeAdapter: destinationAddresses.inkAdapter, | ||
| destinationChainId: DESTINATION_CHAIN_ID() | ||
| }) | ||
| ); | ||
| } | ||
| } |
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
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
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} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol'; | ||
| import {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol'; | ||
|
|
||
| abstract contract BaseAddInkPathPayloadTest 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_ink_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 EthereumAddInkPathPayloadTest is | ||
| Ethereum, | ||
| BaseAddInkPathPayloadTest('ethereum', 22123500) | ||
| { | ||
| function _getDeployedPayload() internal pure override returns (address) { | ||
| return 0x9cdA84ae11d829079EDcCaEd49e473f6fb841b75; | ||
| } | ||
|
|
||
| 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: currentAddresses.inkAdapter, // ethereum -> ink bridge adapter | ||
| destinationChainBridgeAdapter: destinationAddresses.inkAdapter, // ink 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's replace with addresses from address-book