Skip to content

Commit

Permalink
fix: Add new event AddressSetAsProxy for imple address updates
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Jan 5, 2022
1 parent da14cbf commit e4a15fb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
37 changes: 28 additions & 9 deletions contracts/interfaces/IPoolAddressesProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,36 @@ interface IPoolAddressesProvider {
* @notice Emitted when a new proxy is created.
* @param id The identifier of the proxy
* @param proxyAddress The address of the created proxy contract
* @param implementationAddress The address of the implementation contract
*/
event ProxyCreated(bytes32 indexed id, address indexed proxyAddress);
event ProxyCreated(
bytes32 indexed id,
address indexed proxyAddress,
address indexed implementationAddress
);

/**
* @notice Emitted when a new contract address is registered.
* @notice Emitted when a new non-proxied contract address is registered.
* @param id The identifier of the contract
* @param implementationAddress The address of the implementation contract
* @param hasProxy True if the address is registered behind a proxy, false otherwise
* @param oldAddress The address of the old contract
* @param newAddress The address of the new contract
*/
event AddressSet(bytes32 indexed id, address indexed implementationAddress, bool hasProxy);

event AddressSet(bytes32 indexed id, address indexed oldAddress, address indexed newAddress);

/**
* @notice Emitted when a new proxied contract address is registered.
* @param id The identifier of the contract
* @param proxyAddress The address of the proxy contract
* @param oldImplementationAddress The address of the old implementation contract
* @param newImplementationAddress The address of the new implementation contract
*/
event AddressSetAsProxy(
bytes32 indexed id,
address proxyAddress,
address indexed oldImplementationAddress,
address indexed newImplementationAddress
);

/**
* @notice Returns the id of the Aave market to which this contract points to.
* @return The market id
Expand All @@ -102,13 +121,13 @@ interface IPoolAddressesProvider {
/**
* @notice General function to update the implementation of a proxy registered with
* certain `id`. If there is no proxy registered, it will instantiate one and
* set as implementation the `impl`.
* set as implementation the `newImplementationAddress`.
* @dev IMPORTANT Use this function carefully, only for ids that don't have an explicit
* setter function, in order to avoid unexpected consequences
* @param id The id
* @param implementationAddress The address of the new implementation
* @param newImplementationAddress The address of the new implementation
*/
function setAddressAsProxy(bytes32 id, address implementationAddress) external;
function setAddressAsProxy(bytes32 id, address newImplementationAddress) external;

/**
* @notice Sets an address for an id replacing the address saved in the addresses map.
Expand Down
13 changes: 8 additions & 5 deletions contracts/protocol/configuration/PoolAddressesProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@ contract PoolAddressesProvider is Ownable, IPoolAddressesProvider {

/// @inheritdoc IPoolAddressesProvider
function setAddress(bytes32 id, address newAddress) external override onlyOwner {
address oldAddress = _addresses[id];
_addresses[id] = newAddress;
emit AddressSet(id, newAddress, false);
emit AddressSet(id, oldAddress, newAddress);
}

/// @inheritdoc IPoolAddressesProvider
function setAddressAsProxy(bytes32 id, address implementationAddress)
function setAddressAsProxy(bytes32 id, address newImplementationAddress)
external
override
onlyOwner
{
_updateImpl(id, implementationAddress);
emit AddressSet(id, implementationAddress, true);
address proxyAddress = _addresses[id];
address oldImplementationAddress = _getProxyImplementation(id);
_updateImpl(id, newImplementationAddress);
emit AddressSetAsProxy(id, proxyAddress, oldImplementationAddress, newImplementationAddress);
}

/// @inheritdoc IPoolAddressesProvider
Expand Down Expand Up @@ -169,7 +172,7 @@ contract PoolAddressesProvider is Ownable, IPoolAddressesProvider {
_addresses[id] = proxyAddress = address(proxy);
proxy.initialize(newAddress, params);

emit ProxyCreated(id, proxyAddress);
emit ProxyCreated(id, proxyAddress, newAddress);
} else {
proxy.upgradeToAndCall(newAddress, params);
}
Expand Down

0 comments on commit e4a15fb

Please sign in to comment.