-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add e2e for internal bridge tx #186
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
Open
rachit77
wants to merge
5
commits into
main
Choose a base branch
from
test/internal-bridges
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
62e65b1
add test
rachit77 008d768
Merge remote-tracking branch 'origin' into test/internal-bridges
rachit77 a983f98
fix test inventory file
rachit77 2eed1a4
Merge remote-tracking branch 'origin/main' into test/internal-bridges
rachit77 c020658
Merge remote-tracking branch 'origin/main' into test/internal-bridges
rachit77 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,111 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0 | ||
|
|
||
| pragma solidity ^0.8.20; | ||
| import "./Interfaces.sol"; | ||
|
|
||
| contract InternalBridgeTx { | ||
| event MessageReceived(address destinationAddress); | ||
| event BridgeTransactionExecuted(uint32 destinationNetwork, address destinationAddress, uint256 amount); | ||
| event UpdateBridgeParameters(); | ||
|
|
||
| IPolygonZkEVMBridgeV2 public immutable bridgeAddress; | ||
|
|
||
| // First bridge transaction parameters | ||
| uint32 destinationNetwork1; | ||
| address destinationAddress1; | ||
| uint256 amount1; | ||
| address token1; | ||
| bool forceUpdateGlobalExitRoot1; | ||
| bytes permitData1; | ||
|
|
||
| // Second bridge transaction parameters | ||
| uint32 destinationNetwork2; | ||
| address destinationAddress2; | ||
| uint256 amount2; | ||
| address token2; | ||
| bool forceUpdateGlobalExitRoot2; | ||
| bytes permitData2; | ||
|
|
||
| bytes data; | ||
|
|
||
| constructor(IPolygonZkEVMBridgeV2 _bridgeAddress) { | ||
| bridgeAddress = _bridgeAddress; | ||
| } | ||
|
|
||
| function updateBridgeParameters( | ||
| // First bridge transaction parameters | ||
| uint32 _destinationNetwork1, | ||
| address _destinationAddress1, | ||
| uint256 _amount1, | ||
| address _token1, | ||
| bool _forceUpdateGlobalExitRoot1, | ||
| bytes calldata _permitData1, | ||
| // Second bridge transaction parameters | ||
| uint32 _destinationNetwork2, | ||
| address _destinationAddress2, | ||
| uint256 _amount2, | ||
| address _token2, | ||
| bool _forceUpdateGlobalExitRoot2, | ||
| bytes calldata _permitData2 | ||
| ) public { | ||
| // Set first bridge transaction parameters | ||
| destinationNetwork1 = _destinationNetwork1; | ||
| destinationAddress1 = _destinationAddress1; | ||
| amount1 = _amount1; | ||
| token1 = _token1; | ||
| forceUpdateGlobalExitRoot1 = _forceUpdateGlobalExitRoot1; | ||
| permitData1 = _permitData1; | ||
|
|
||
| // Set second bridge transaction parameters | ||
| destinationNetwork2 = _destinationNetwork2; | ||
| destinationAddress2 = _destinationAddress2; | ||
| amount2 = _amount2; | ||
| token2 = _token2; | ||
| forceUpdateGlobalExitRoot2 = _forceUpdateGlobalExitRoot2; | ||
| permitData2 = _permitData2; | ||
|
|
||
| emit UpdateBridgeParameters(); | ||
| } | ||
|
|
||
| function onMessageReceived( | ||
| bytes memory data1 | ||
| ) external payable { | ||
| data = data1; | ||
|
|
||
| // First bridge transaction | ||
| try bridgeAddress.bridgeAsset{value: amount1}( | ||
| destinationNetwork1, | ||
| destinationAddress1, | ||
| amount1, | ||
| token1, | ||
| forceUpdateGlobalExitRoot1, | ||
| permitData1 | ||
| ) { | ||
| emit BridgeTransactionExecuted(destinationNetwork1, destinationAddress1, amount1); | ||
| } catch { | ||
| // First bridge transaction failed, continue with second transaction | ||
| } | ||
|
|
||
| // Second bridge transaction | ||
| try bridgeAddress.bridgeAsset{value: amount2}( | ||
| destinationNetwork2, | ||
| destinationAddress2, | ||
| amount2, | ||
| token2, | ||
| forceUpdateGlobalExitRoot2, | ||
| permitData2 | ||
| ) { | ||
| emit BridgeTransactionExecuted(destinationNetwork2, destinationAddress2, amount2); | ||
| } catch { | ||
| // Second bridge transaction failed, transaction continues | ||
| } | ||
|
|
||
| emit MessageReceived(msg.sender); | ||
| } | ||
|
|
||
| // Function to receive ETH | ||
| receive() external payable {} | ||
|
|
||
| // Fallback function | ||
| fallback() external payable {} | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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.
@rachit77 change this before merging