Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): Add setter to IAddressManager of AddressResolver #13799

Merged
merged 4 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 setIAddressManager(address newAddressManager) external onlyOwner {
adaki2004 marked this conversation as resolved.
Show resolved Hide resolved
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