-
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.
Merge pull request #811 from matter-labs/kl/l2-native-token
fix: l2-native-token, bridge fixes
- Loading branch information
Showing
58 changed files
with
2,146 additions
and
902 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import {IBridgedStandardToken} from "./interfaces/IBridgedStandardToken.sol"; | |
import {Unauthorized, NonSequentialVersion, ZeroAddress} from "../common/L1ContractErrors.sol"; | ||
import {L2_NATIVE_TOKEN_VAULT_ADDR} from "../common/L2ContractAddresses.sol"; | ||
import {DataEncoding} from "../common/libraries/DataEncoding.sol"; | ||
import {INativeTokenVault} from "../bridge/ntv/INativeTokenVault.sol"; | ||
|
||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
|
@@ -43,13 +44,20 @@ contract BridgedStandardERC20 is ERC20PermitUpgradeable, IBridgedStandardToken, | |
/// @dev Address of the native token vault that is used as trustee who can mint/burn tokens | ||
address public nativeTokenVault; | ||
|
||
/// @dev The assetId of the token. | ||
bytes32 public assetId; | ||
|
||
/// @dev This also sets the native token vault to the default value if it is not set. | ||
/// It is not set only on the L2s for legacy tokens. | ||
modifier onlyNTV() { | ||
address ntv = nativeTokenVault; | ||
if (ntv == address(0)) { | ||
ntv = L2_NATIVE_TOKEN_VAULT_ADDR; | ||
nativeTokenVault = L2_NATIVE_TOKEN_VAULT_ADDR; | ||
assetId = DataEncoding.encodeNTVAssetId( | ||
INativeTokenVault(L2_NATIVE_TOKEN_VAULT_ADDR).L1_CHAIN_ID(), | ||
originToken | ||
); | ||
} | ||
if (msg.sender != ntv) { | ||
revert Unauthorized(msg.sender); | ||
|
@@ -74,14 +82,20 @@ contract BridgedStandardERC20 is ERC20PermitUpgradeable, IBridgedStandardToken, | |
|
||
/// @notice Initializes a contract token for later use. Expected to be used in the proxy. | ||
/// @dev Stores the L1 address of the bridge and set `name`/`symbol`/`decimals` getters that L1 token has. | ||
/// @param _assetId The assetId of the token. | ||
/// @param _originToken Address of the origin token that can be deposited to mint this bridged token | ||
/// @param _data The additional data that the L1 bridge provide for initialization. | ||
/// In this case, it is packed `name`/`symbol`/`decimals` of the L1 token. | ||
function bridgeInitialize(address _originToken, bytes calldata _data) external initializer returns (uint256) { | ||
function bridgeInitialize( | ||
bytes32 _assetId, | ||
address _originToken, | ||
bytes calldata _data | ||
) external initializer returns (uint256) { | ||
if (_originToken == address(0)) { | ||
revert ZeroAddress(); | ||
} | ||
originToken = _originToken; | ||
assetId = _assetId; | ||
|
||
nativeTokenVault = msg.sender; | ||
|
||
|
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 |
---|---|---|
|
@@ -2,17 +2,19 @@ | |
|
||
pragma solidity ^0.8.20; | ||
|
||
import {IAssetRouterBase} from "./IAssetRouterBase.sol"; | ||
|
||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
interface IL2AssetRouter { | ||
interface IL2AssetRouter is IAssetRouterBase { | ||
event WithdrawalInitiatedAssetRouter( | ||
uint256 chainId, | ||
address indexed l2Sender, | ||
bytes32 indexed assetId, | ||
bytes assetData | ||
); | ||
|
||
function withdraw(bytes32 _assetId, bytes calldata _transferData) external; | ||
function withdraw(bytes32 _assetId, bytes calldata _transferData) external returns (bytes32); | ||
|
||
function l1AssetRouter() 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
Oops, something went wrong.