-
Couldn't load subscription status.
- Fork 75
improve(ZkSync_SpokePool): Read l2Bridge dynamically #1094
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,11 @@ import "./SpokePool.sol"; | |
|
|
||
| // https://github.com/matter-labs/era-contracts/blob/6391c0d7bf6184d7f6718060e3991ba6f0efe4a7/zksync/contracts/bridge/L2ERC20Bridge.sol#L104 | ||
| interface ZkBridgeLike { | ||
| function withdraw( | ||
| address _l1Receiver, | ||
| address _l2Token, | ||
| uint256 _amount | ||
| ) external; | ||
| function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external; | ||
| } | ||
|
|
||
| interface IZkErc20 { | ||
| function l2Bridge() external view returns (address); | ||
| } | ||
|
|
||
| interface IL2ETH { | ||
|
|
@@ -166,7 +166,13 @@ contract ZkSync_SpokePool is SpokePool, CircleCCTPAdapter { | |
| zkUSDCBridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | ||
| } | ||
| } else { | ||
| zkErc20Bridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | ||
| // Elastic chain bridged tokens advertise custom bridge interface via the l2Bridge() getter. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See:
|
||
| address l2Bridge = IZkErc20(l2TokenAddress).l2Bridge(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo: Add test |
||
| if (l2Bridge != address(0)) { | ||
| ZkBridgeLike(l2Bridge).withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tbd catch andrevert to zkErc20Bridge? These tokens are managed by governance, so there's some control over which interfaces the ERC20s implement. |
||
| } else { | ||
| zkErc20Bridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
This is being reflowed by the commit hook. Not sure when that was implemented.