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
|
* @title LendingPoolAddressesProvider contract
|
||||||
* @dev Main registry of addresses part or connected to the protocol.
|
* @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 it's implementations
|
* - Acting also as factory of proxies and admin of those, so with right to change its implementations
|
||||||
* - Owned by the Aave Governance
|
* - Owned by the Aave Governance
|
||||||
* @author Aave
|
* @author Aave
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -9,31 +9,19 @@ import {Errors} from '../libraries/helpers/Errors.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title LendingPoolAddressesProviderRegistry contract
|
* @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
|
* @author Aave
|
||||||
**/
|
**/
|
||||||
|
|
||||||
contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesProviderRegistry {
|
contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesProviderRegistry {
|
||||||
mapping(address => uint256) private _addressesProviders;
|
mapping(address => uint256) private _addressesProviders;
|
||||||
address[] private _addressesProvidersList;
|
address[] private _addressesProvidersList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev returns if an addressesProvider is registered or not
|
* @dev Returns the list of registered addresses provider
|
||||||
* @param provider the addresses provider
|
* @return The list of addresses provider, potentially containing address(0) elements
|
||||||
* @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
|
|
||||||
**/
|
**/
|
||||||
function getAddressesProvidersList() external override view returns (address[] memory) {
|
function getAddressesProvidersList() external override view returns (address[] memory) {
|
||||||
address[] memory addressesProvidersList = _addressesProvidersList;
|
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
|
* @dev Registers an addresses provider
|
||||||
* @param provider the pool address to be registered
|
* @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 {
|
function registerAddressesProvider(address provider, uint256 id) external override onlyOwner {
|
||||||
require(id != 0, Errors.LPAPR_INVALID_ADDRESSES_PROVIDER_ID);
|
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
|
* @dev Removes a LendingPoolAddressesProvider from the list of registered addresses provider
|
||||||
* @param provider the pool address to be unregistered
|
* @param provider The LendingPoolAddressesProvider address
|
||||||
**/
|
**/
|
||||||
function unregisterAddressesProvider(address provider) external override onlyOwner {
|
function unregisterAddressesProvider(address provider) external override onlyOwner {
|
||||||
require(_addressesProviders[provider] > 0, Errors.LPAPR_PROVIDER_NOT_REGISTERED);
|
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
|
* @dev Returns the id on a registered LendingPoolAddressesProvider
|
||||||
* @param provider the pool address to be added
|
* @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 {
|
function _addToAddressesProvidersList(address provider) internal {
|
||||||
uint256 providersCount = _addressesProvidersList.length;
|
uint256 providersCount = _addressesProvidersList.length;
|
||||||
|
|
||||||
|
@ -88,17 +86,4 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
||||||
|
|
||||||
_addressesProvidersList.push(provider);
|
_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;
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@title ILendingPoolAddressesProvider interface
|
* @title LendingPoolAddressesProvider contract
|
||||||
@notice provides the interface to fetch the Aave protocol address
|
* @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 {
|
interface ILendingPoolAddressesProvider {
|
||||||
event LendingPoolUpdated(address indexed newAddress);
|
event LendingPoolUpdated(address indexed newAddress);
|
||||||
event ConfigurationAdminUpdated(address indexed newAddress);
|
event ConfigurationAdminUpdated(address indexed newAddress);
|
||||||
|
@ -18,15 +20,9 @@ interface ILendingPoolAddressesProvider {
|
||||||
event ProxyCreated(bytes32 id, address indexed newAddress);
|
event ProxyCreated(bytes32 id, address indexed newAddress);
|
||||||
event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);
|
event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);
|
||||||
|
|
||||||
function setAddress(
|
function setAddress(bytes32 id, address newAddress) external;
|
||||||
bytes32 id,
|
|
||||||
address newAddress
|
|
||||||
) external;
|
|
||||||
|
|
||||||
function setAddressAsProxy(
|
function setAddressAsProxy(bytes32 id, address impl) external;
|
||||||
bytes32 id,
|
|
||||||
address impl
|
|
||||||
) external;
|
|
||||||
|
|
||||||
function getAddress(bytes32 id) external view returns (address);
|
function getAddress(bytes32 id) external view returns (address);
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ILendingPoolAddressesProvider interface
|
* @title LendingPoolAddressesProviderRegistry contract
|
||||||
* @notice provides the interface to fetch the LendingPoolCore address
|
* @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 {
|
interface ILendingPoolAddressesProviderRegistry {
|
||||||
event AddressesProviderRegistered(address indexed newAddress);
|
event AddressesProviderRegistered(address indexed newAddress);
|
||||||
|
@ -11,8 +15,6 @@ interface ILendingPoolAddressesProviderRegistry {
|
||||||
|
|
||||||
function getAddressesProvidersList() external view returns (address[] memory);
|
function getAddressesProvidersList() external view returns (address[] memory);
|
||||||
|
|
||||||
function isAddressesProviderRegistered(address provider) external view returns (uint256);
|
|
||||||
|
|
||||||
function getAddressesProviderIdByAddress(address addressesProvider)
|
function getAddressesProviderIdByAddress(address addressesProvider)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
|
|
|
@ -44,8 +44,7 @@ makeSuite('AddressesProviderRegistry', (testEnv: TestEnv) => {
|
||||||
it('Removes the mock addresses provider', async () => {
|
it('Removes the mock addresses provider', async () => {
|
||||||
const {users, registry, addressesProvider} = testEnv;
|
const {users, registry, addressesProvider} = testEnv;
|
||||||
|
|
||||||
//checking the isAddressesProviderRegistered function
|
const id = await registry.getAddressesProviderIdByAddress(users[1].address);
|
||||||
const id = await registry.isAddressesProviderRegistered(users[1].address);
|
|
||||||
|
|
||||||
expect(id).to.be.equal('2', 'Invalid isRegistered return value');
|
expect(id).to.be.equal('2', 'Invalid isRegistered return value');
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ makeSuite('AddressesProviderRegistry', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
const providers = await registry.getAddressesProvidersList();
|
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');
|
expect(providers.length).to.be.equal(2, 'Invalid length of the addresses providers list');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user