-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Danil <[email protected]> Co-authored-by: Neo <[email protected]> Co-authored-by: tommysr <[email protected]> Co-authored-by: Rahul Saxena <[email protected]> Co-authored-by: Artem Makhortov <[email protected]> Co-authored-by: Bence Haromi <[email protected]> Co-authored-by: Zach Kolodny <[email protected]> Co-authored-by: Stanislav Bezkorovainyi <[email protected]> Co-authored-by: Vlad Bochok <[email protected]> Co-authored-by: perekopskiy <[email protected]> Co-authored-by: perekopskiy <[email protected]> Co-authored-by: Danil <[email protected]> Co-authored-by: Ivan Schasny <[email protected]> Co-authored-by: Raid5594 <[email protected]> Co-authored-by: Raid Ateir <[email protected]>
- Loading branch information
1 parent
a91bc7a
commit 391fa4d
Showing
70 changed files
with
2,096 additions
and
444 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol | |
|
||
import {IL1NativeTokenVault} from "./interfaces/IL1NativeTokenVault.sol"; | ||
import {IL1AssetHandler} from "./interfaces/IL1AssetHandler.sol"; | ||
|
||
import {IL1AssetRouter} from "./interfaces/IL1AssetRouter.sol"; | ||
import {ETH_TOKEN_ADDRESS} from "../common/Config.sol"; | ||
import {DataEncoding} from "../common/libraries/DataEncoding.sol"; | ||
|
@@ -23,7 +22,7 @@ import {BridgeHelper} from "./BridgeHelper.sol"; | |
/// @custom:security-contact [email protected] | ||
/// @dev Vault holding L1 native ETH and ERC20 tokens bridged into the ZK chains. | ||
/// @dev Designed for use with a proxy for upgradability. | ||
contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2StepUpgradeable, PausableUpgradeable { | ||
contract L1NativeTokenVault is IL1NativeTokenVault, Ownable2StepUpgradeable, PausableUpgradeable { | ||
using SafeERC20 for IERC20; | ||
|
||
/// @dev The address of the WETH token on L1. | ||
|
@@ -220,10 +219,15 @@ contract L1NativeTokenVault is IL1NativeTokenVault, IL1AssetHandler, Ownable2Ste | |
} | ||
|
||
/// @dev Receives and parses (name, symbol, decimals) from the token contract | ||
function getERC20Getters(address _token) public view returns (bytes memory) { | ||
function getERC20Getters(address _token) public view override returns (bytes memory) { | ||
return BridgeHelper.getERC20Getters(_token, ETH_TOKEN_ADDRESS); | ||
} | ||
|
||
/// @dev Shows the assetId for a given chain and token address | ||
function getAssetId(uint256 _chainId, address _l1Token) external pure override returns (bytes32) { | ||
return DataEncoding.encodeNTVAssetId(_chainId, _l1Token); | ||
} | ||
|
||
/// @dev Transfers tokens from the depositor address to the smart contract address. | ||
/// @return The difference between the contract balance before and after the transferring of funds. | ||
function _depositFunds(address _from, IERC20 _token, uint256 _amount) internal returns (uint256) { | ||
|
12 changes: 12 additions & 0 deletions
12
l1-contracts/contracts/bridge/interfaces/IL1BaseTokenAssetHandler.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,12 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
/// @title L1 Base Token Asset Handler contract interface | ||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
/// @notice Used for any asset handler and called by the L1AssetRouter | ||
interface IL1BaseTokenAssetHandler { | ||
/// @notice Used to get the token address of an assetId | ||
function tokenAddress(bytes32 _assetId) external view returns (address); | ||
} |
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 |
---|---|---|
|
@@ -3,12 +3,14 @@ | |
pragma solidity 0.8.24; | ||
|
||
import {IL1AssetRouter} from "./IL1AssetRouter.sol"; | ||
import {IL1AssetHandler} from "./IL1AssetHandler.sol"; | ||
import {IL1BaseTokenAssetHandler} from "./IL1BaseTokenAssetHandler.sol"; | ||
|
||
/// @title L1 Native token vault contract interface | ||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
/// @notice The NTV is an Asset Handler for the L1AssetRouter to handle native tokens | ||
interface IL1NativeTokenVault { | ||
interface IL1NativeTokenVault is IL1AssetHandler, IL1BaseTokenAssetHandler { | ||
/// @notice The L1AssetRouter contract | ||
function L1_SHARED_BRIDGE() external view returns (IL1AssetRouter); | ||
|
||
|
@@ -24,6 +26,6 @@ interface IL1NativeTokenVault { | |
/// @notice Used the get token balance for specific ZK chain in shared bridge | ||
function chainBalance(uint256 _chainId, address _l1Token) external view returns (uint256); | ||
|
||
/// @notice Used to get the token address of an assetId | ||
function tokenAddress(bytes32 _assetId) external view returns (address); | ||
/// @dev Shows the assetId for a given chain and token address | ||
function getAssetId(uint256 _chainId, address _l1Token) external pure 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
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
Oops, something went wrong.