change variable name
This commit is contained in:
@ -5,7 +5,7 @@ import "./interfaces/IUniswapV2.sol";
|
|||||||
|
|
||||||
contract UniswapV2Factory is IUniswapV2Factory {
|
contract UniswapV2Factory is IUniswapV2Factory {
|
||||||
bytes public exchangeBytecode;
|
bytes public exchangeBytecode;
|
||||||
address public factoryOwner;
|
address public feeToSetter;
|
||||||
address public feeTo;
|
address public feeTo;
|
||||||
|
|
||||||
mapping (address => mapping(address => address)) private _getExchange;
|
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);
|
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");
|
require(_exchangeBytecode.length >= 32, "UniswapV2Factory: SHORT_BYTECODE");
|
||||||
exchangeBytecode = _exchangeBytecode;
|
exchangeBytecode = _exchangeBytecode;
|
||||||
factoryOwner = _factoryOwner;
|
feeToSetter = _feeToSetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortTokens(address tokenA, address tokenB) public pure returns (address token0, address token1) {
|
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);
|
emit ExchangeCreated(token0, token1, exchange, exchanges.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFactoryOwner(address _factoryOwner) external {
|
function setFeeToSetter(address _feeToSetter) external {
|
||||||
require(msg.sender == factoryOwner, "UniswapV2Factory: FORBIDDEN");
|
require(msg.sender == feeToSetter, "UniswapV2Factory: FORBIDDEN");
|
||||||
factoryOwner = _factoryOwner;
|
feeToSetter = _feeToSetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFeeTo(address _feeTo) external {
|
function setFeeTo(address _feeTo) external {
|
||||||
require(msg.sender == factoryOwner, "UniswapV2Factory: FORBIDDEN");
|
require(msg.sender == feeToSetter, "UniswapV2Factory: FORBIDDEN");
|
||||||
feeTo = _feeTo;
|
feeTo = _feeTo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ interface IUniswapV2Factory {
|
|||||||
event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint256);
|
event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint256);
|
||||||
|
|
||||||
function exchangeBytecode() external view returns (bytes memory);
|
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 feeTo() external view returns (address);
|
||||||
|
|
||||||
function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);
|
function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);
|
||||||
|
|||||||
@ -31,9 +31,9 @@ describe('UniswapV2Factory', () => {
|
|||||||
factory = _factory
|
factory = _factory
|
||||||
})
|
})
|
||||||
|
|
||||||
it('exchangeBytecode, factoryOwner, feeTo, exchangesCount', async () => {
|
it('exchangeBytecode, feeToSetter, feeTo, exchangesCount', async () => {
|
||||||
expect(await factory.exchangeBytecode()).to.eq(bytecode)
|
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.feeTo()).to.eq(AddressZero)
|
||||||
expect(await factory.exchangesCount()).to.eq(0)
|
expect(await factory.exchangesCount()).to.eq(0)
|
||||||
})
|
})
|
||||||
@ -81,11 +81,11 @@ describe('UniswapV2Factory', () => {
|
|||||||
console.log(`Gas required for createExchange: ${gasCost}`)
|
console.log(`Gas required for createExchange: ${gasCost}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('setFactoryOwner', async () => {
|
it('setFeeToSetter', async () => {
|
||||||
await expect(factory.connect(other).setFactoryOwner(other.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN
|
await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN
|
||||||
await factory.setFactoryOwner(other.address)
|
await factory.setFeeToSetter(other.address)
|
||||||
expect(await factory.factoryOwner()).to.eq(other.address)
|
expect(await factory.feeToSetter()).to.eq(other.address)
|
||||||
await expect(factory.setFactoryOwner(wallet.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN
|
await expect(factory.setFeeToSetter(wallet.address)).to.be.reverted // UniswapV2Factory: FORBIDDEN
|
||||||
})
|
})
|
||||||
|
|
||||||
it('setFeeTo', async () => {
|
it('setFeeTo', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user