fix tests related to bytecode

This commit is contained in:
Noah Zinsmeister
2020-01-08 13:04:01 -05:00
parent f2d4021498
commit 9f15d75925
3 changed files with 11 additions and 16 deletions

View File

@ -1,8 +1,8 @@
pragma solidity 0.5.15;
import "./UniswapV2.sol";
import "./interfaces/IUniswapV2Factory.sol";
import "./interfaces/IUniswapV2.sol";
import "./UniswapV2.sol";
contract UniswapV2Factory is IUniswapV2Factory {
address public feeToSetter;
@ -35,10 +35,10 @@ contract UniswapV2Factory is IUniswapV2Factory {
require(tokenA != address(0) && tokenB != address(0), "UniswapV2Factory: ZERO_ADDRESS");
(address token0, address token1) = sortTokens(tokenA, tokenB);
require(getExchange_[token0][token1] == address(0), "UniswapV2Factory: EXCHANGE_EXISTS");
bytes memory exchangeBytecodeMemory = type(UniswapV2).creationCode;
bytes memory exchangeBytecode = type(UniswapV2).creationCode;
bytes32 salt = keccak256(abi.encodePacked(token0, token1));
assembly { // solium-disable-line security/no-inline-assembly
exchange := create2(0, add(exchangeBytecodeMemory, 32), mload(exchangeBytecodeMemory), salt)
exchange := create2(0, add(exchangeBytecode, 32), mload(exchangeBytecode), salt)
}
IUniswapV2(exchange).initialize(token0, token1);
getExchange_[token0][token1] = exchange;