diff --git a/contracts/UniswapV2Factory.sol b/contracts/UniswapV2Factory.sol index 7bd418f..25704c4 100644 --- a/contracts/UniswapV2Factory.sol +++ b/contracts/UniswapV2Factory.sol @@ -5,7 +5,7 @@ import "./interfaces/IUniswapV2.sol"; contract UniswapV2Factory is IUniswapV2Factory { bytes public exchangeBytecode; - address public factoryOwner; + address public feeToSetter; address public feeTo; mapping (address => mapping(address => address)) private _getExchange; @@ -13,10 +13,10 @@ contract UniswapV2Factory is IUniswapV2Factory { event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint); - constructor(bytes memory _exchangeBytecode, address _factoryOwner) public { + constructor(bytes memory _exchangeBytecode, address _feeToSetter) public { require(_exchangeBytecode.length >= 32, "UniswapV2Factory: SHORT_BYTECODE"); exchangeBytecode = _exchangeBytecode; - factoryOwner = _factoryOwner; + feeToSetter = _feeToSetter; } function sortTokens(address tokenA, address tokenB) public pure returns (address token0, address token1) { @@ -48,13 +48,13 @@ contract UniswapV2Factory is IUniswapV2Factory { emit ExchangeCreated(token0, token1, exchange, exchanges.length); } - function setFactoryOwner(address _factoryOwner) external { - require(msg.sender == factoryOwner, "UniswapV2Factory: FORBIDDEN"); - factoryOwner = _factoryOwner; + function setFeeToSetter(address _feeToSetter) external { + require(msg.sender == feeToSetter, "UniswapV2Factory: FORBIDDEN"); + feeToSetter = _feeToSetter; } function setFeeTo(address _feeTo) external { - require(msg.sender == factoryOwner, "UniswapV2Factory: FORBIDDEN"); + require(msg.sender == feeToSetter, "UniswapV2Factory: FORBIDDEN"); feeTo = _feeTo; } } diff --git a/contracts/interfaces/IUniswapV2Factory.sol b/contracts/interfaces/IUniswapV2Factory.sol index e72ddd9..cc8c2d7 100644 --- a/contracts/interfaces/IUniswapV2Factory.sol +++ b/contracts/interfaces/IUniswapV2Factory.sol @@ -4,7 +4,7 @@ interface IUniswapV2Factory { event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint256); function exchangeBytecode() external view returns (bytes memory); - function factoryOwner() external view returns (address); + function feeToSetter() external view returns (address); function feeTo() external view returns (address); function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1); diff --git a/test/UniswapV2Factory.spec.ts b/test/UniswapV2Factory.spec.ts index ad733d9..4494459 100644 --- a/test/UniswapV2Factory.spec.ts +++ b/test/UniswapV2Factory.spec.ts @@ -31,9 +31,9 @@ describe('UniswapV2Factory', () => { factory = _factory }) - it('exchangeBytecode, factoryOwner, feeTo, exchangesCount', async () => { + it('exchangeBytecode, feeToSetter, feeTo, exchangesCount', async () => { expect(await factory.exchangeBytecode()).to.eq(bytecode) - expect(await factory.factoryOwner()).to.eq(wallet.address) + expect(await factory.feeToSetter()).to.eq(wallet.address) expect(await factory.feeTo()).to.eq(AddressZero) expect(await factory.exchangesCount()).to.eq(0) }) @@ -81,11 +81,11 @@ describe('UniswapV2Factory', () => { console.log(`Gas required for createExchange: ${gasCost}`) }) - it('setFactoryOwner', async () => { - await expect(factory.connect(other).setFactoryOwner(other.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN - await factory.setFactoryOwner(other.address) - expect(await factory.factoryOwner()).to.eq(other.address) - await expect(factory.setFactoryOwner(wallet.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN + it('setFeeToSetter', async () => { + await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN + await factory.setFeeToSetter(other.address) + expect(await factory.feeToSetter()).to.eq(other.address) + await expect(factory.setFeeToSetter(wallet.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN }) it('setFeeTo', async () => {