From e9e087c328f96bddf61f46300e5286d49d3411d2 Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Mon, 30 Dec 2019 13:30:15 -0500 Subject: [PATCH] remove getTokens from the factory --- contracts/UniswapV2Factory.sol | 6 ------ contracts/interfaces/IUniswapV2Factory.sol | 1 - test/UniswapV2Factory.spec.ts | 1 - test/shared/fixtures.ts | 2 +- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/contracts/UniswapV2Factory.sol b/contracts/UniswapV2Factory.sol index 35bb425..f6ca589 100644 --- a/contracts/UniswapV2Factory.sol +++ b/contracts/UniswapV2Factory.sol @@ -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)); } diff --git a/contracts/interfaces/IUniswapV2Factory.sol b/contracts/interfaces/IUniswapV2Factory.sol index 040aa22..b2bc844 100644 --- a/contracts/interfaces/IUniswapV2Factory.sol +++ b/contracts/interfaces/IUniswapV2Factory.sol @@ -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); diff --git a/test/UniswapV2Factory.spec.ts b/test/UniswapV2Factory.spec.ts index a292de3..c6bf75c 100644 --- a/test/UniswapV2Factory.spec.ts +++ b/test/UniswapV2Factory.spec.ts @@ -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) diff --git a/test/shared/fixtures.ts b/test/shared/fixtures.ts index d6aab21..9646faf 100644 --- a/test/shared/fixtures.ts +++ b/test/shared/fixtures.ts @@ -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