mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	- Fixed comments on LendingPoolAddressesProviderRegistry and removed useless getter.
This commit is contained in:
		
							parent
							
								
									4192a5d992
								
							
						
					
					
						commit
						a5f9332234
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
 **/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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];
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user