Skip to content

Commit

Permalink
Fix audittens m03 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless authored Dec 2, 2024
1 parent aeade7e commit 7663cfc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions l1-contracts/contracts/bridge/asset-router/IL2AssetRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface IL2AssetRouter is IAssetRouterBase {

function withdraw(bytes32 _assetId, bytes calldata _transferData) external returns (bytes32);

function withdrawToken(address _l2NativeToken, bytes memory _assetData) external returns (bytes32);

function l1AssetRouter() external view returns (address);

function withdrawLegacyBridge(address _l1Receiver, address _l2Token, uint256 _amount, address _sender) external;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter {
function _ensureTokenRegisteredWithNTV(address _token) internal override returns (bytes32 assetId) {
IL2NativeTokenVault nativeTokenVault = IL2NativeTokenVault(L2_NATIVE_TOKEN_VAULT_ADDR);
nativeTokenVault.ensureTokenIsRegistered(_token);
assetId = nativeTokenVault.assetId(_token);
}

/*//////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {IL2NativeTokenVault} from "contracts/bridge/ntv/IL2NativeTokenVault.sol"
import {UpgradeableBeacon} from "@openzeppelin/contracts-v4/proxy/beacon/UpgradeableBeacon.sol";
import {BeaconProxy} from "@openzeppelin/contracts-v4/proxy/beacon/BeaconProxy.sol";

import {L2_ASSET_ROUTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR, L2_BRIDGEHUB_ADDR} from "contracts/common/L2ContractAddresses.sol";
import {L2_ASSET_ROUTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR, L2_BRIDGEHUB_ADDR, L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR} from "contracts/common/L2ContractAddresses.sol";
import {ETH_TOKEN_ADDRESS, SETTLEMENT_LAYER_RELAY_SENDER} from "contracts/common/Config.sol";

import {AddressAliasHelper} from "contracts/vendor/AddressAliasHelper.sol";
Expand All @@ -31,6 +31,7 @@ import {IZKChain} from "contracts/state-transition/chain-interfaces/IZKChain.sol
import {SystemContractsArgs} from "./_SharedL2ContractL1DeployerUtils.sol";

import {DeployUtils} from "deploy-scripts/DeployUtils.s.sol";
import {TestnetERC20Token} from "contracts/dev-contracts/TestnetERC20Token.sol";

abstract contract L2Erc20TestAbstract is Test, SharedL2ContractDeployer {
function performDeposit(address depositor, address receiver, uint256 amount) internal {
Expand Down Expand Up @@ -96,4 +97,20 @@ abstract contract L2Erc20TestAbstract is Test, SharedL2ContractDeployer {
vm.prank(ownerWallet);
BridgedStandardERC20(l2TokenAddress).reinitializeToken(getters, "TestTokenNewName", "TTN", 20);
}

function test_withdrawToken() external {
TestnetERC20Token l2NativeToken = new TestnetERC20Token("token", "T", 18);

l2NativeToken.mint(address(this), 100);
l2NativeToken.approve(L2_NATIVE_TOKEN_VAULT_ADDR, 100);

// Basically we want all L2->L1 transactions to pass
vm.mockCall(
L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,
abi.encodeWithSignature("sendToL1(bytes)"),
abi.encode(bytes32(uint256(1)))
);

IL2AssetRouter(L2_ASSET_ROUTER_ADDR).withdrawToken(address(l2NativeToken), abi.encode(100, address(1)));
}
}

0 comments on commit 7663cfc

Please sign in to comment.