Remove redundant getters from bridges
This commit is contained in:
		@@ -55,7 +55,7 @@ contract Eth2DaiBridge is
 | 
			
		||||
        // Decode the bridge data to get the `fromTokenAddress`.
 | 
			
		||||
        (address fromTokenAddress) = abi.decode(bridgeData, (address));
 | 
			
		||||
 | 
			
		||||
        IEth2Dai exchange = _getEth2DaiContract();
 | 
			
		||||
        IEth2Dai exchange = IEth2Dai(_getEth2DaiAddress());
 | 
			
		||||
        // Grant an allowance to the exchange to spend `fromTokenAddress` token.
 | 
			
		||||
        LibERC20Token.approve(fromTokenAddress, address(exchange), uint256(-1));
 | 
			
		||||
 | 
			
		||||
@@ -84,14 +84,4 @@ contract Eth2DaiBridge is
 | 
			
		||||
    {
 | 
			
		||||
        return LEGACY_WALLET_MAGIC_VALUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Overridable way to get the eth2dai contract.
 | 
			
		||||
    /// @return exchange The Eth2Dai exchange contract.
 | 
			
		||||
    function _getEth2DaiContract()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IEth2Dai exchange)
 | 
			
		||||
    {
 | 
			
		||||
        return IEth2Dai(_getEth2DaiAddress());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -77,8 +77,8 @@ contract KyberBridge is
 | 
			
		||||
        returns (bytes4 success)
 | 
			
		||||
    {
 | 
			
		||||
        TradeState memory state;
 | 
			
		||||
        state.kyber = _getKyberContract();
 | 
			
		||||
        state.weth = _getWETHContract();
 | 
			
		||||
        state.kyber = IKyberNetworkProxy(_getKyberNetworkProxyAddress());
 | 
			
		||||
        state.weth = IEtherToken(_getWethAddress());
 | 
			
		||||
        // Decode the bridge data to get the `fromTokenAddress`.
 | 
			
		||||
        (state.fromTokenAddress) = abi.decode(bridgeData, (address));
 | 
			
		||||
        state.fromTokenBalance = IERC20Token(state.fromTokenAddress).balanceOf(address(this));
 | 
			
		||||
@@ -143,24 +143,4 @@ contract KyberBridge is
 | 
			
		||||
    {
 | 
			
		||||
        return LEGACY_WALLET_MAGIC_VALUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Overridable way to get the `KyberNetworkProxy` contract.
 | 
			
		||||
    /// @return kyber The `IKyberNetworkProxy` contract.
 | 
			
		||||
    function _getKyberContract()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IKyberNetworkProxy kyber)
 | 
			
		||||
    {
 | 
			
		||||
        return IKyberNetworkProxy(_getKyberNetworkProxyAddress());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Overridable way to get the WETH contract.
 | 
			
		||||
    /// @return weth The WETH contract.
 | 
			
		||||
    function _getWETHContract()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IEtherToken weth)
 | 
			
		||||
    {
 | 
			
		||||
        return IEtherToken(_getWETHAddress());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,7 @@ contract UniswapBridge is
 | 
			
		||||
        // Get our balance of `fromTokenAddress` token.
 | 
			
		||||
        state.fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
 | 
			
		||||
        // Get the weth contract.
 | 
			
		||||
        state.weth = getWethContract();
 | 
			
		||||
        state.weth = IEtherToken(_getWethAddress());
 | 
			
		||||
 | 
			
		||||
        // Convert from WETH to a token.
 | 
			
		||||
        if (fromTokenAddress == address(state.weth)) {
 | 
			
		||||
@@ -161,26 +161,6 @@ contract UniswapBridge is
 | 
			
		||||
        return LEGACY_WALLET_MAGIC_VALUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Overridable way to get the weth contract.
 | 
			
		||||
    /// @return token The WETH contract.
 | 
			
		||||
    function getWethContract()
 | 
			
		||||
        public
 | 
			
		||||
        view
 | 
			
		||||
        returns (IEtherToken token)
 | 
			
		||||
    {
 | 
			
		||||
        return IEtherToken(_getWETHAddress());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Overridable way to get the uniswap exchange factory contract.
 | 
			
		||||
    /// @return factory The exchange factory contract.
 | 
			
		||||
    function getUniswapExchangeFactoryContract()
 | 
			
		||||
        public
 | 
			
		||||
        view
 | 
			
		||||
        returns (IUniswapExchangeFactory factory)
 | 
			
		||||
    {
 | 
			
		||||
        return IUniswapExchangeFactory(_getUniswapExchangeFactoryAddress());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Grants an unlimited allowance to the exchange for its token
 | 
			
		||||
    ///      on behalf of this contract.
 | 
			
		||||
    /// @param exchange The Uniswap token exchange.
 | 
			
		||||
@@ -207,11 +187,12 @@ contract UniswapBridge is
 | 
			
		||||
    {
 | 
			
		||||
        address exchangeTokenAddress = fromTokenAddress;
 | 
			
		||||
        // Whichever isn't WETH is the exchange token.
 | 
			
		||||
        if (fromTokenAddress == address(getWethContract())) {
 | 
			
		||||
        if (fromTokenAddress == _getWethAddress()) {
 | 
			
		||||
            exchangeTokenAddress = toTokenAddress;
 | 
			
		||||
        }
 | 
			
		||||
        exchange = IUniswapExchange(
 | 
			
		||||
            getUniswapExchangeFactoryContract().getExchange(exchangeTokenAddress)
 | 
			
		||||
            IUniswapExchangeFactory(_getUniswapExchangeFactoryAddress())
 | 
			
		||||
            .getExchange(exchangeTokenAddress)
 | 
			
		||||
        );
 | 
			
		||||
        require(address(exchange) != address(0), "NO_UNISWAP_EXCHANGE_FOR_TOKEN");
 | 
			
		||||
        return exchange;
 | 
			
		||||
 
 | 
			
		||||
@@ -192,11 +192,11 @@ contract TestEth2DaiBridge is
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // @dev This contract will double as the Eth2Dai contract.
 | 
			
		||||
    function _getEth2DaiContract()
 | 
			
		||||
    function _getEth2DaiAddress()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IEth2Dai)
 | 
			
		||||
        returns (address)
 | 
			
		||||
    {
 | 
			
		||||
        return IEth2Dai(address(this));
 | 
			
		||||
        return address(this);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -303,20 +303,20 @@ contract TestKyberBridge is
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // @dev overridden to point to this contract.
 | 
			
		||||
    function _getKyberContract()
 | 
			
		||||
    function _getKyberNetworkProxyAddress()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IKyberNetworkProxy kyber)
 | 
			
		||||
        returns (address)
 | 
			
		||||
    {
 | 
			
		||||
        return IKyberNetworkProxy(address(this));
 | 
			
		||||
        return address(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // @dev overridden to point to test WETH.
 | 
			
		||||
    function _getWETHContract()
 | 
			
		||||
    function _getWethAddress()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IEtherToken weth_)
 | 
			
		||||
        returns (address)
 | 
			
		||||
    {
 | 
			
		||||
        return weth;
 | 
			
		||||
        return address(weth);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -413,20 +413,20 @@ contract TestUniswapBridge is
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // @dev Use `wethToken`.
 | 
			
		||||
    function getWethContract()
 | 
			
		||||
        public
 | 
			
		||||
    function _getWethAddress()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IEtherToken)
 | 
			
		||||
        returns (address)
 | 
			
		||||
    {
 | 
			
		||||
        return IEtherToken(address(wethToken));
 | 
			
		||||
        return address(wethToken);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // @dev This contract will double as the Uniswap contract.
 | 
			
		||||
    function getUniswapExchangeFactoryContract()
 | 
			
		||||
        public
 | 
			
		||||
    function _getUniswapExchangeFactoryAddress()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IUniswapExchangeFactory)
 | 
			
		||||
        returns (address)
 | 
			
		||||
    {
 | 
			
		||||
        return IUniswapExchangeFactory(address(this));
 | 
			
		||||
        return address(this);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user