Skip to content

Commit acc0056

Browse files
committed
Bring scope of ReverseRegistrarShim into ReverseRegistrarV2
1 parent 8d95036 commit acc0056

3 files changed

Lines changed: 83 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
- name: Run Forge build
3636
run: |
3737
forge --version
38-
forge build --sizes
3938
id: build
4039

4140
- name: Run Forge tests

src/L2/ReverseRegistrarV2.sol

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.23;
33

4+
import {AddrResolver} from "ens-contracts/resolvers/profiles/AddrResolver.sol";
45
import {ENS} from "ens-contracts/registry/ENS.sol";
6+
import {IL2ReverseRegistrar} from "src/L2/interface/IL2ReverseRegistrar.sol";
57
import {NameResolver} from "ens-contracts/resolvers/profiles/NameResolver.sol";
6-
import {AddrResolver} from "ens-contracts/resolvers/profiles/AddrResolver.sol";
78
import {Ownable} from "solady/auth/Ownable.sol";
89

910
import {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`.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.4;
3+
4+
/// @notice Interface for the L2 Reverse Registrar.
5+
interface IL2ReverseRegistrar {
6+
/// @notice Sets the `nameForAddr()` record for the calling account.
7+
///
8+
/// @param name The name to set.
9+
function setName(string memory name) external;
10+
11+
/// @notice Sets the `nameForAddr()` record for the addr provided account.
12+
///
13+
/// @param addr The address to set the name for.
14+
/// @param name The name to set.
15+
function setNameForAddr(address addr, string memory name) external;
16+
17+
/// @notice Sets the `nameForAddr()` record for the addr provided account using a signature.
18+
///
19+
/// @param addr The address to set the name for.
20+
/// @param name The name to set.
21+
/// @param coinTypes The coin types to set. Must be inclusive of the coin type for the contract.
22+
/// @param signatureExpiry Date when the signature expires.
23+
/// @param signature The signature from the addr.
24+
function setNameForAddrWithSignature(
25+
address addr,
26+
uint256 signatureExpiry,
27+
string memory name,
28+
uint256[] memory coinTypes,
29+
bytes memory signature
30+
) external;
31+
32+
/// @notice Sets the `nameForAddr()` record for the contract provided that is owned with `Ownable`.
33+
///
34+
/// @param contractAddr The address of the contract to set the name for (implementing Ownable).
35+
/// @param owner The owner of the contract (via Ownable).
36+
/// @param signatureExpiry The expiry of the signature.
37+
/// @param name The name to set.
38+
/// @param coinTypes The coin types to set. Must be inclusive of the coin type for the contract.
39+
/// @param signature The signature of an address that will return true on isValidSignature for the owner.
40+
function setNameForOwnableWithSignature(
41+
address contractAddr,
42+
address owner,
43+
uint256 signatureExpiry,
44+
string memory name,
45+
uint256[] memory coinTypes,
46+
bytes memory signature
47+
) external;
48+
}

0 commit comments

Comments
 (0)