11//SPDX-License-Identifier: MIT
22pragma solidity ^ 0.8.23 ;
33
4+ import {AddrResolver} from "ens-contracts/resolvers/profiles/AddrResolver.sol " ;
45import {ENS} from "ens-contracts/registry/ENS.sol " ;
6+ import {IL2ReverseRegistrar} from "src/L2/interface/IL2ReverseRegistrar.sol " ;
57import {NameResolver} from "ens-contracts/resolvers/profiles/NameResolver.sol " ;
6- import {AddrResolver} from "ens-contracts/resolvers/profiles/AddrResolver.sol " ;
78import {Ownable} from "solady/auth/Ownable.sol " ;
89
910import {Sha3} from "src/lib/Sha3.sol " ;
@@ -28,14 +29,17 @@ contract ReverseRegistrarV2 is Ownable {
2829 /// @notice The reverse node this registrar manages.
2930 bytes32 public immutable reverseNode;
3031
32+ /// @notice The address of the ENS-deployed L2ReverseRegistrar contract.
33+ address public immutable l2ReverseRegistrar;
34+
3135 /// @notice The network cointype.
3236 uint256 public immutable cointype;
3337
3438 /// @notice Permissioned controller contracts.
3539 mapping (address controller = > bool approved ) public controllers;
3640
3741 /// @notice The default resolver for setting Name resolution records.
38- NameResolver public defaultResolver;
42+ address public defaultResolver;
3943
4044 /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
4145 /* ERRORS */
@@ -63,7 +67,7 @@ contract ReverseRegistrarV2 is Ownable {
6367 /// @notice Emitted when the default Resolver is changed by the `owner`.
6468 ///
6569 /// @param resolver The address of the new Resolver.
66- event DefaultResolverChanged (NameResolver indexed resolver );
70+ event DefaultResolverChanged (address indexed resolver );
6771
6872 /// @notice Emitted when a controller address approval status is changed by the `owner`.
6973 ///
@@ -104,13 +108,37 @@ contract ReverseRegistrarV2 is Ownable {
104108 /// @param owner_ The permissioned address initialized as the `owner` in the `Ownable` context.
105109 /// @param reverseNode_ The network-sepcific reverse node.
106110 /// @param cointype_ The network-specific cointype.
107- constructor (ENS registry_ , address owner_ , bytes32 reverseNode_ , uint256 cointype_ ) {
111+ constructor (ENS registry_ , address owner_ , bytes32 reverseNode_ , address l2ReverseRegistrar_ , uint256 cointype_ ) {
108112 _initializeOwner (owner_);
109113 registry = registry_;
110114 reverseNode = reverseNode_;
115+ l2ReverseRegistrar = l2ReverseRegistrar_;
111116 cointype = cointype_;
112117 }
113118
119+ /// @notice Sets the reverse record `name` for `addr`.
120+ ///
121+ /// @dev First calls the ENS L2ReverseRegistrar and sets the name-record for the provided address. Then follows the legacy
122+ /// Basenames reverse registrar flow.
123+ ///
124+ /// @param addr The name records will be set for this address.
125+ /// @param name The name that will be stored for `addr`.
126+ /// @param signatureExpiry The timestamp expiration of the signature.
127+ /// @param cointypes The array of networks-as-cointypes used in replayable reverse sets.
128+ /// @param signature The signature bytes.
129+ function setNameForAddrWithSignature (
130+ address addr ,
131+ string calldata name ,
132+ uint256 signatureExpiry ,
133+ uint256 [] memory cointypes ,
134+ bytes memory signature
135+ ) external returns (bytes32 ) {
136+ IL2ReverseRegistrar (l2ReverseRegistrar).setNameForAddrWithSignature (
137+ addr, signatureExpiry, name, cointypes, signature
138+ );
139+ return setNameForAddr (addr, msg .sender , defaultResolver, name);
140+ }
141+
114142 /// @notice Allows the owner to back populate the ENSIP-11 forward resolution records for basenames.
115143 ///
116144 /// @dev For each node in `nodes` we make a series of checks to make sure that we're
@@ -126,7 +154,7 @@ contract ReverseRegistrarV2 is Ownable {
126154
127155 // Get the resolver address for the node and check that it is our public resolver.
128156 address resolverAddr = registry.resolver (_node);
129- if (address ( resolverAddr) != address ( defaultResolver) ) continue ;
157+ if (resolverAddr != defaultResolver) continue ;
130158 AddrResolver resolver = AddrResolver (resolverAddr);
131159
132160 // Get the `addr` record for the node and check validity.
@@ -149,7 +177,7 @@ contract ReverseRegistrarV2 is Ownable {
149177 /// @param resolver The address of the new resolver.
150178 function setDefaultResolver (address resolver ) public onlyOwner {
151179 if (address (resolver) == address (0 )) revert NoZeroAddress ();
152- defaultResolver = NameResolver ( resolver) ;
180+ defaultResolver = resolver;
153181 registry.setResolver (reverseNode, resolver);
154182 emit DefaultResolverChanged (defaultResolver);
155183 }
@@ -170,7 +198,7 @@ contract ReverseRegistrarV2 is Ownable {
170198 ///
171199 /// @return The ENS node hash of the base-specific reverse record.
172200 function claim (address owner ) public returns (bytes32 ) {
173- return claimForBaseAddr (msg .sender , owner, address ( defaultResolver) );
201+ return claimForBaseAddr (msg .sender , owner, defaultResolver);
174202 }
175203
176204 /// @notice Transfers ownership of the base-specific reverse ENS record for `addr` to the provided `owner`.
0 commit comments