-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Raid Ateir
committed
Dec 18, 2024
1 parent
0810ca1
commit a70eae5
Showing
27 changed files
with
113 additions
and
846 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
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
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ import {AddressAliasHelper} from "../../vendor/AddressAliasHelper.sol"; | |
import {L2_NATIVE_TOKEN_VAULT_ADDR, L2_BRIDGEHUB_ADDR} from "../../common/L2ContractAddresses.sol"; | ||
import {L2ContractHelper} from "../../common/libraries/L2ContractHelper.sol"; | ||
import {DataEncoding} from "../../common/libraries/DataEncoding.sol"; | ||
import {EmptyAddress, InvalidCaller, AmountMustBeGreaterThanZero, AssetIdNotSupported} from "../../common/L1ContractErrors.sol"; | ||
import {TokenNotLegacy, EmptyAddress, InvalidCaller, AmountMustBeGreaterThanZero, AssetIdNotSupported} from "../../common/L1ContractErrors.sol"; | ||
|
||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
|
@@ -68,6 +68,13 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
_; | ||
} | ||
|
||
modifier onlyNTV() { | ||
if (msg.sender != L2_NATIVE_TOKEN_VAULT_ADDR) { | ||
revert InvalidCaller(msg.sender); | ||
} | ||
_; | ||
} | ||
|
||
/// @dev Disable the initialization to prevent Parity hack. | ||
/// @dev this contract is deployed in the L2GenesisUpgrade, and is meant as direct deployment without a proxy. | ||
/// @param _l1AssetRouter The address of the L1 Bridge contract. | ||
|
@@ -108,6 +115,12 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
_setAssetHandlerAddressThisChain(L2_NATIVE_TOKEN_VAULT_ADDR, _assetRegistrationData, _assetHandlerAddress); | ||
} | ||
|
||
function setLegacyTokenAssetHandler(bytes32 _assetId) external override onlyNTV { | ||
// Note, that it is an asset handler, but not asset deployment tracker, | ||
// which is located on L1. | ||
_setAssetHandler(_assetId, L2_NATIVE_TOKEN_VAULT_ADDR); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
Receive transaction Functions | ||
//////////////////////////////////////////////////////////////*/ | ||
|
@@ -120,13 +133,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
uint256, | ||
bytes32 _assetId, | ||
bytes calldata _transferData | ||
) | ||
public | ||
payable | ||
override(AssetRouterBase, IAssetRouterBase) | ||
onlyAssetRouterCounterpartOrSelf(L1_CHAIN_ID) | ||
nonReentrant | ||
{ | ||
) public override(AssetRouterBase, IAssetRouterBase) onlyAssetRouterCounterpartOrSelf(L1_CHAIN_ID) { | ||
if (_assetId == BASE_TOKEN_ASSET_ID) { | ||
revert AssetIdNotSupported(BASE_TOKEN_ASSET_ID); | ||
} | ||
|
@@ -144,7 +151,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
/// @dev do not rely on this function, it will be deprecated in the future | ||
/// @param _assetId The asset id of the withdrawn asset | ||
/// @param _assetData The data that is passed to the asset handler contract | ||
function withdraw(bytes32 _assetId, bytes memory _assetData) public override { | ||
function withdraw(bytes32 _assetId, bytes calldata _assetData) external returns (bytes32) { | ||
_withdrawSender(_assetId, _assetData, msg.sender, true); | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -5,6 +5,13 @@ pragma solidity ^0.8.20; | |
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
interface IL2SharedBridgeLegacy { | ||
event FinalizeDeposit( | ||
address indexed l1Sender, | ||
address indexed l2Receiver, | ||
address indexed l2Token, | ||
uint256 amount | ||
); | ||
|
||
function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external; | ||
|
||
function l1TokenAddress(address _l2Token) external view returns (address); | ||
|
@@ -17,5 +24,5 @@ interface IL2SharedBridgeLegacy { | |
|
||
function deployBeaconProxy(bytes32 _salt) external returns (address); | ||
|
||
function sendMessageToL1(bytes calldata _message) external; | ||
function sendMessageToL1(bytes calldata _message) external returns (bytes32); | ||
} |
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 |
---|---|---|
|
@@ -15,14 +15,15 @@ import {NativeTokenVault} from "./NativeTokenVault.sol"; | |
|
||
import {IL2SharedBridgeLegacy} from "../interfaces/IL2SharedBridgeLegacy.sol"; | ||
import {BridgedStandardERC20} from "../BridgedStandardERC20.sol"; | ||
import {IL2AssetRouter} from "../asset-router/IL2AssetRouter.sol"; | ||
|
||
import {L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, L2_ASSET_ROUTER_ADDR} from "../../common/L2ContractAddresses.sol"; | ||
import {L2ContractHelper, IContractDeployer} from "../../common/libraries/L2ContractHelper.sol"; | ||
|
||
import {SystemContractsCaller} from "../../common/libraries/SystemContractsCaller.sol"; | ||
import {DataEncoding} from "../../common/libraries/DataEncoding.sol"; | ||
|
||
import {EmptyAddress, EmptyBytes32, AddressMismatch, DeployFailed, AssetIdNotSupported, ZeroAddress} from "../../common/L1ContractErrors.sol"; | ||
import {AssetIdAlreadyRegistered, NoLegacySharedBridge, TokenIsNotLegacy, EmptyAddress, EmptyBytes32, AddressMismatch, DeployFailed, AssetIdNotSupported} from "../../common/L1ContractErrors.sol"; | ||
|
||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
|
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
Oops, something went wrong.