@@ -5,16 +5,15 @@ import {ENS} from "ens-contracts/registry/ENS.sol";
5
5
import {NameResolver} from "ens-contracts/resolvers/profiles/NameResolver.sol " ;
6
6
import {Ownable} from "solady/auth/Ownable.sol " ;
7
7
8
- import {BASE_REVERSE_NODE} from "src/util/Constants.sol " ;
9
8
import {Sha3} from "src/lib/Sha3.sol " ;
10
9
11
10
/// @title Reverse Registrar
12
11
///
13
12
/// @notice Registrar which allows registrants to establish a name as their "primary" record for reverse resolution.
14
13
/// Inspired by ENS's ReverseRegistrar implementation:
15
14
/// https://github.com/ensdomains/ens-contracts/blob/staging/contracts/reverseRegistrar/ReverseRegistrar.sol
16
- /// Writes records to the base -specific reverse node, compliant with ENSIP-19
17
- /// https://docs.ens.domains/ensip/19
15
+ /// Writes records to the network -specific reverse node set on construction via `reverseNode`.
16
+ /// Compliant with ENSIP-19: https://docs.ens.domains/ensip/19
18
17
///
19
18
/// @author Coinbase (https://github.com/base-org/usernames)
20
19
/// @author ENS (https://github.com/ensdomains/ens-contracts)
@@ -26,6 +25,9 @@ contract ReverseRegistrar is Ownable {
26
25
/// @notice The Registry contract.
27
26
ENS public immutable registry;
28
27
28
+ /// @notice The reverse node this registrar manages.
29
+ bytes32 public immutable reverseNode;
30
+
29
31
/// @notice Permissioned controller contracts.
30
32
mapping (address controller = > bool approved ) public controllers;
31
33
@@ -97,9 +99,10 @@ contract ReverseRegistrar is Ownable {
97
99
///
98
100
/// @param registry_ The ENS registry, will be stored as `registry`.
99
101
/// @param owner_ The permissioned address initialized as the `owner` in the `Ownable` context.
100
- constructor (ENS registry_ , address owner_ ) {
102
+ constructor (ENS registry_ , address owner_ , bytes32 reverseNode_ ) {
101
103
_initializeOwner (owner_);
102
104
registry = registry_;
105
+ reverseNode = reverseNode_;
103
106
}
104
107
105
108
/// @notice Allows the owner to change the address of the default resolver.
@@ -111,7 +114,7 @@ contract ReverseRegistrar is Ownable {
111
114
function setDefaultResolver (address resolver ) public onlyOwner {
112
115
if (address (resolver) == address (0 )) revert NoZeroAddress ();
113
116
defaultResolver = NameResolver (resolver);
114
- registry.setResolver (BASE_REVERSE_NODE , resolver);
117
+ registry.setResolver (reverseNode , resolver);
115
118
emit DefaultResolverChanged (defaultResolver);
116
119
}
117
120
@@ -150,9 +153,9 @@ contract ReverseRegistrar is Ownable {
150
153
returns (bytes32 )
151
154
{
152
155
bytes32 labelHash = Sha3.hexAddress (addr);
153
- bytes32 baseReverseNode = keccak256 (abi.encodePacked (BASE_REVERSE_NODE , labelHash));
156
+ bytes32 baseReverseNode = keccak256 (abi.encodePacked (reverseNode , labelHash));
154
157
emit BaseReverseClaimed (addr, baseReverseNode);
155
- registry.setSubnodeRecord (BASE_REVERSE_NODE , labelHash, owner, resolver, 0 );
158
+ registry.setSubnodeRecord (reverseNode , labelHash, owner, resolver, 0 );
156
159
return baseReverseNode;
157
160
}
158
161
@@ -202,8 +205,8 @@ contract ReverseRegistrar is Ownable {
202
205
/// @param addr The address to hash.
203
206
///
204
207
/// @return The base-specific reverse node hash.
205
- function node (address addr ) public pure returns (bytes32 ) {
206
- return keccak256 (abi.encodePacked (BASE_REVERSE_NODE , Sha3.hexAddress (addr)));
208
+ function node (address addr ) public view returns (bytes32 ) {
209
+ return keccak256 (abi.encodePacked (reverseNode , Sha3.hexAddress (addr)));
207
210
}
208
211
209
212
/// @notice Allows this contract to check if msg.sender is the `Ownable:owner()` for `addr`.
0 commit comments