From a5f9332234599f28dd2acb45b980eba7d4601556 Mon Sep 17 00:00:00 2001 From: eboado Date: Thu, 19 Nov 2020 14:21:36 +0100 Subject: [PATCH] - Fixed comments on LendingPoolAddressesProviderRegistry and removed useless getter. --- .../LendingPoolAddressesProvider.sol | 4 +- .../LendingPoolAddressesProviderRegistry.sol | 61 +++++++------------ .../ILendingPoolAddressesProvider.sol | 20 +++--- .../ILendingPoolAddressesProviderRegistry.sol | 10 +-- test/addresses-provider-registry.spec.ts | 5 +- 5 files changed, 41 insertions(+), 59 deletions(-) diff --git a/contracts/configuration/LendingPoolAddressesProvider.sol b/contracts/configuration/LendingPoolAddressesProvider.sol index c4ef76d6..88164aab 100644 --- a/contracts/configuration/LendingPoolAddressesProvider.sol +++ b/contracts/configuration/LendingPoolAddressesProvider.sol @@ -11,8 +11,8 @@ import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddresses /** * @title LendingPoolAddressesProvider contract - * @dev Main registry of addresses part or connected to the protocol. - * - Acting also as factory of proxies and admin of those, so with right to change it's implementations + * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles + * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Aave Governance * @author Aave **/ diff --git a/contracts/configuration/LendingPoolAddressesProviderRegistry.sol b/contracts/configuration/LendingPoolAddressesProviderRegistry.sol index 4be6e034..1d805bec 100644 --- a/contracts/configuration/LendingPoolAddressesProviderRegistry.sol +++ b/contracts/configuration/LendingPoolAddressesProviderRegistry.sol @@ -9,31 +9,19 @@ import {Errors} from '../libraries/helpers/Errors.sol'; /** * @title LendingPoolAddressesProviderRegistry contract - * @notice contains the list of active addresses providers + * @dev Main registry of LendingPoolAddressesProvider of multiple Aave protocol's markets + * - Used for indexing purposes of Aave protocol's markets + * - The id assigned to a LendingPoolAddressesProvider refers to the market it is connected with, + * for example with `0` for the Aave main market and `1` for the next created * @author Aave **/ - contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesProviderRegistry { mapping(address => uint256) private _addressesProviders; address[] private _addressesProvidersList; /** - * @dev returns if an addressesProvider is registered or not - * @param provider the addresses provider - * @return The id of the addresses provider or 0 if the addresses provider not registered - **/ - function isAddressesProviderRegistered(address provider) - external - override - view - returns (uint256) - { - return _addressesProviders[provider]; - } - - /** - * @dev returns the list of active addressesProviders - * @return the list of addressesProviders, potentially containing address(0) elements + * @dev Returns the list of registered addresses provider + * @return The list of addresses provider, potentially containing address(0) elements **/ function getAddressesProvidersList() external override view returns (address[] memory) { address[] memory addressesProvidersList = _addressesProvidersList; @@ -52,8 +40,9 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP } /** - * @dev adds a lending pool to the list of registered lending pools - * @param provider the pool address to be registered + * @dev Registers an addresses provider + * @param provider The address of the new LendingPoolAddressesProvider + * @param id The id for the new LendingPoolAddressesProvider, referring to the market it belongs to **/ function registerAddressesProvider(address provider, uint256 id) external override onlyOwner { require(id != 0, Errors.LPAPR_INVALID_ADDRESSES_PROVIDER_ID); @@ -64,8 +53,8 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP } /** - * @dev removes a lending pool from the list of registered lending pools - * @param provider the pool address to be unregistered + * @dev Removes a LendingPoolAddressesProvider from the list of registered addresses provider + * @param provider The LendingPoolAddressesProvider address **/ function unregisterAddressesProvider(address provider) external override onlyOwner { require(_addressesProviders[provider] > 0, Errors.LPAPR_PROVIDER_NOT_REGISTERED); @@ -74,9 +63,18 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP } /** - * @dev adds to the list of the addresses providers, if it wasn't already added before - * @param provider the pool address to be added - **/ + * @dev Returns the id on a registered LendingPoolAddressesProvider + * @return The id or 0 if the LendingPoolAddressesProvider is not registered + */ + function getAddressesProviderIdByAddress(address addressesProvider) + external + override + view + returns (uint256) + { + return _addressesProviders[addressesProvider]; + } + function _addToAddressesProvidersList(address provider) internal { uint256 providersCount = _addressesProvidersList.length; @@ -88,17 +86,4 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP _addressesProvidersList.push(provider); } - - /** - * @dev Returns the id on an `addressesProvider` or address(0) if not registered - * @return The id or 0 if the addresses provider is not registered - */ - function getAddressesProviderIdByAddress(address addressesProvider) - external - override - view - returns (uint256) - { - return _addressesProviders[addressesProvider]; - } } diff --git a/contracts/interfaces/ILendingPoolAddressesProvider.sol b/contracts/interfaces/ILendingPoolAddressesProvider.sol index c1a7ab78..092bf72b 100644 --- a/contracts/interfaces/ILendingPoolAddressesProvider.sol +++ b/contracts/interfaces/ILendingPoolAddressesProvider.sol @@ -2,10 +2,12 @@ pragma solidity ^0.6.8; /** -@title ILendingPoolAddressesProvider interface -@notice provides the interface to fetch the Aave protocol address - */ - + * @title LendingPoolAddressesProvider contract + * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles + * - Acting also as factory of proxies and admin of those, so with right to change its implementations + * - Owned by the Aave Governance + * @author Aave + **/ interface ILendingPoolAddressesProvider { event LendingPoolUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); @@ -18,15 +20,9 @@ interface ILendingPoolAddressesProvider { event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); - function setAddress( - bytes32 id, - address newAddress - ) external; + function setAddress(bytes32 id, address newAddress) external; - function setAddressAsProxy( - bytes32 id, - address impl - ) external; + function setAddressAsProxy(bytes32 id, address impl) external; function getAddress(bytes32 id) external view returns (address); diff --git a/contracts/interfaces/ILendingPoolAddressesProviderRegistry.sol b/contracts/interfaces/ILendingPoolAddressesProviderRegistry.sol index 87c0c651..5ff2776e 100644 --- a/contracts/interfaces/ILendingPoolAddressesProviderRegistry.sol +++ b/contracts/interfaces/ILendingPoolAddressesProviderRegistry.sol @@ -2,8 +2,12 @@ pragma solidity ^0.6.8; /** - * @title ILendingPoolAddressesProvider interface - * @notice provides the interface to fetch the LendingPoolCore address + * @title LendingPoolAddressesProviderRegistry contract + * @dev Main registry of LendingPoolAddressesProvider of multiple Aave protocol's markets + * - Used for indexing purposes of Aave protocol's markets + * - The id assigned to a LendingPoolAddressesProvider refers to the market it is connected with, + * for example with `0` for the Aave main market and `1` for the next created + * @author Aave **/ interface ILendingPoolAddressesProviderRegistry { event AddressesProviderRegistered(address indexed newAddress); @@ -11,8 +15,6 @@ interface ILendingPoolAddressesProviderRegistry { function getAddressesProvidersList() external view returns (address[] memory); - function isAddressesProviderRegistered(address provider) external view returns (uint256); - function getAddressesProviderIdByAddress(address addressesProvider) external view diff --git a/test/addresses-provider-registry.spec.ts b/test/addresses-provider-registry.spec.ts index caa135e2..d26eae21 100644 --- a/test/addresses-provider-registry.spec.ts +++ b/test/addresses-provider-registry.spec.ts @@ -44,8 +44,7 @@ makeSuite('AddressesProviderRegistry', (testEnv: TestEnv) => { it('Removes the mock addresses provider', async () => { const {users, registry, addressesProvider} = testEnv; - //checking the isAddressesProviderRegistered function - const id = await registry.isAddressesProviderRegistered(users[1].address); + const id = await registry.getAddressesProviderIdByAddress(users[1].address); expect(id).to.be.equal('2', 'Invalid isRegistered return value'); @@ -88,7 +87,7 @@ makeSuite('AddressesProviderRegistry', (testEnv: TestEnv) => { const providers = await registry.getAddressesProvidersList(); - const id = await registry.isAddressesProviderRegistered(addressesProvider.address); + const id = await registry.getAddressesProviderIdByAddress(addressesProvider.address); expect(providers.length).to.be.equal(2, 'Invalid length of the addresses providers list');