diff --git a/packages/protocol/contracts/common/AddressResolver.sol b/packages/protocol/contracts/common/AddressResolver.sol index 677947f4194..4f4c8d99fd9 100644 --- a/packages/protocol/contracts/common/AddressResolver.sol +++ b/packages/protocol/contracts/common/AddressResolver.sol @@ -29,6 +29,8 @@ abstract contract AddressResolver { _; } + event AddressManagerChanged(address addressManager); + /** * Resolves a name to an address on the current chain. * diff --git a/packages/protocol/contracts/common/EssentialContract.sol b/packages/protocol/contracts/common/EssentialContract.sol index a5e0ecaa7cd..5f9e7ed6e73 100644 --- a/packages/protocol/contracts/common/EssentialContract.sol +++ b/packages/protocol/contracts/common/EssentialContract.sol @@ -6,6 +6,7 @@ pragma solidity ^0.8.18; +import {IAddressManager} from "./AddressManager.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; @@ -25,4 +26,16 @@ abstract contract EssentialContract is OwnableUpgradeable.__Ownable_init(); AddressResolver._init(_addressManager); } + + /** + * Sets a new AddressManager's address. + * + * @param newAddressManager New address manager contract address + */ + function setAddressManager(address newAddressManager) external onlyOwner { + if (newAddressManager == address(0)) revert RESOLVER_INVALID_ADDR(); + _addressManager = IAddressManager(newAddressManager); + + emit IAddressManagerChanged(address(this), newAddressManager); + } } diff --git a/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md b/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md index 7055db9fe8a..dac0bc61179 100644 --- a/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md +++ b/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md @@ -37,6 +37,12 @@ error RESOLVER_ZERO_ADDR(uint256 chainId, bytes32 name) modifier onlyFromNamed(bytes32 name) ``` +### IAddressManagerChanged + +```solidity +event IAddressManagerChanged(address changedOn, address newAddress) +``` + ### resolve ```solidity