Skip to content

Commit

Permalink
refactor: remove UniversalTokenLib
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Oct 22, 2024
1 parent 3a211e6 commit 2ab2f6e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeE
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

import {BridgeTransactionV2Lib} from "./libs/BridgeTransactionV2.sol";
import {UniversalTokenLib} from "./libs/UniversalToken.sol";

import {Admin} from "./Admin.sol";
import {IFastBridge} from "./interfaces/IFastBridge.sol";
Expand All @@ -17,7 +16,6 @@ import {IZapRecipient} from "./interfaces/IZapRecipient.sol";
contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
using BridgeTransactionV2Lib for bytes;
using SafeERC20 for IERC20;
using UniversalTokenLib for address;

/// @notice Address reserved for native gas token (ETH on Ethereum and most L2s, AVAX on Avalanche, etc)
address public constant NATIVE_GAS_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
Expand Down Expand Up @@ -389,8 +387,9 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
} else {
// For ERC20s, token is explicitly transferred from the user to FastBridgeV2.
// We don't allow non-zero `msg.value` to avoid extra funds from being stuck in FastBridgeV2.
token.assertIsContract();
if (msg.value != 0) revert MsgValueIncorrect();
// Throw an explicit error if the provided token address is not a contract
if (token.code.length == 0) revert TokenNotContract();
amountTaken = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
// Use the balance difference as the amount taken in case of fee on transfer tokens.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface IFastBridgeV2Errors {
error MsgValueIncorrect();
error SenderIncorrect();
error StatusIncorrect();
error TokenNotContract();
error ZapDataLengthAboveMax();
error ZapNativeNotSupported();
error ZeroAddress();
Expand Down
1 change: 0 additions & 1 deletion packages/contracts-rfq/test/FastBridgeV2.Src.FBRV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ contract FastBridgeV2SrcFBRouterV2Test is FastBridgeV2SrcTest {
address public router;

error FastBridgeRouterV2__OriginSenderNotSpecified();
error TokenNotContract();

function setUp() public virtual override {
super.setUp();
Expand Down

0 comments on commit 2ab2f6e

Please sign in to comment.