Skip to content

Commit

Permalink
feat(protocol): Add setter to IAddressManager of AddressResolver (#13799
Browse files Browse the repository at this point in the history
)

Co-authored-by: adaki2004 <[email protected]>
Co-authored-by: Brecht Devos <[email protected]>
  • Loading branch information
3 people authored May 23, 2023
1 parent 8aa0940 commit 34de89c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/protocol/contracts/common/AddressResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ abstract contract AddressResolver {
_;
}

event AddressManagerChanged(address addressManager);

/**
* Resolves a name to an address on the current chain.
*
Expand Down
13 changes: 13 additions & 0 deletions packages/protocol/contracts/common/EssentialContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34de89c

Please sign in to comment.