remove getTokens from the factory

This commit is contained in:
Noah Zinsmeister
2019-12-30 13:30:15 -05:00
parent e98b353c46
commit e9e087c328
4 changed files with 1 additions and 9 deletions

View File

@ -9,7 +9,6 @@ contract UniswapV2Factory is IUniswapV2Factory {
address public feeRecipient;
mapping (address => mapping(address => address)) private _getExchange;
mapping (address => address[2]) private _getTokens;
address[] public exchanges;
event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint);
@ -29,10 +28,6 @@ contract UniswapV2Factory is IUniswapV2Factory {
return _getExchange[token0][token1];
}
function getTokens(address exchange) external view returns (address token0, address token1) {
return (_getTokens[exchange][0], _getTokens[exchange][1]);
}
function exchangesCount() external view returns (uint) {
return exchanges.length;
}
@ -49,7 +44,6 @@ contract UniswapV2Factory is IUniswapV2Factory {
}
IUniswapV2(exchange).initialize(token0, token1);
_getExchange[token0][token1] = exchange;
_getTokens[exchange] = [token0, token1];
emit ExchangeCreated(token0, token1, exchange, exchanges.push(exchange));
}

View File

@ -9,7 +9,6 @@ interface IUniswapV2Factory {
function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);
function getExchange(address tokenA, address tokenB) external view returns (address exchange);
function getTokens(address exchange) external view returns (address token0, address token1);
function exchanges(uint) external view returns (address exchange);
function exchangesCount() external view returns (uint);

View File

@ -58,7 +58,6 @@ describe('UniswapV2Factory', () => {
await expect(factory.createExchange(...tokens.slice().reverse())).to.be.reverted // UniswapV2Factory: EXCHANGE_EXISTS
expect(await factory.getExchange(...tokens)).to.eq(create2Address)
expect(await factory.getExchange(...tokens.slice().reverse())).to.eq(create2Address)
expect(await factory.getTokens(create2Address)).to.deep.eq([TEST_ADDRESSES.token0, TEST_ADDRESSES.token1])
expect(await factory.exchanges(0)).to.eq(create2Address)
expect(await factory.exchangesCount()).to.eq(1)

View File

@ -37,7 +37,7 @@ export async function exchangeFixture(provider: providers.Web3Provider, [wallet]
const exchangeAddress = await factory.getExchange(tokenA.address, tokenB.address)
const exchange = new Contract(exchangeAddress, JSON.stringify(UniswapV2.abi), provider)
const [token0Address] = await factory.getTokens(exchangeAddress)
const token0Address = (await exchange.token0()).address
const token0 = tokenA.address === token0Address ? tokenA : tokenB
const token1 = tokenA.address === token0Address ? tokenB : tokenA