Skip to content

Commit

Permalink
Merge text/name resolver into main contract
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflau committed Nov 1, 2023
1 parent 2b66f4f commit 7530428
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 93 deletions.
71 changes: 58 additions & 13 deletions contracts/reverseRegistrar/L2ReverseRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ import "./IL2ReverseRegistrar.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "../resolvers/profiles/ITextResolver.sol";
import "../resolvers/profiles/INameResolver.sol";
import "../root/Controllable.sol";
import "./profiles/L2NameResolver.sol";
import "./profiles/L2TextResolver.sol";
import "./profiles/L2ReverseResolverBase.sol";
import "./L2ReverseResolverBase.sol";

error InvalidSignature();

contract L2ReverseRegistrar is
Ownable,
ITextResolver,
INameResolver,
IL2ReverseRegistrar,
L2ReverseResolverBase,
L2NameResolver,
L2TextResolver
L2ReverseResolverBase
{
using ECDSA for bytes32;
mapping(bytes32 => uint256) public lastUpdated;

event ReverseClaimed(address indexed addr, bytes32 indexed node);
event DefaultResolverChanged(L2NameResolver indexed resolver);

/**
* @dev Constructor
Expand Down Expand Up @@ -284,6 +283,55 @@ contract L2ReverseRegistrar is
return node;
}

mapping(uint64 => mapping(bytes32 => mapping(string => string))) versionable_texts;

function _setText(
bytes32 node,
string calldata key,
string calldata value
) internal {
versionable_texts[recordVersions[node]][node][key] = value;
emit TextChanged(node, key, key, value);
}

/**
* Returns the text data associated with an ENS node and key.
* @param node The ENS node to query.
* @param key The text data key to query.
* @return The associated text data.
*/
function text(
bytes32 node,
string calldata key
) external view virtual override returns (string memory) {
return versionable_texts[recordVersions[node]][node][key];
}

mapping(uint64 => mapping(bytes32 => string)) versionable_names;

This comment has been minimized.

Copy link
@makoto

makoto Nov 1, 2023

Member

@Arachnid didn't you say that you don't want to make reverse resolver not versionable?

This comment has been minimized.

Copy link
@Arachnid

Arachnid Nov 1, 2023

Member

It's worth at least discussing. I don't think there's a lot of value in supporting versioning in the reverse resolver.

This comment has been minimized.

Copy link
@makoto

makoto Nov 1, 2023

Member

May not need it if it only needs to set a name, but this PR also includes setText which may want to have versioning (and if text has it then name should also has it for consistency purpose)

/**
* Sets the name associated with an ENS node, for reverse records.
* May only be called by the owner of that node in the ENS registry.
* @param node The node to update.
* @param newName name record
*/
function _setName(bytes32 node, string memory newName) internal virtual {
versionable_names[recordVersions[node]][node] = newName;
emit NameChanged(node, newName);
}

/**
* Returns the name associated with an ENS node, for reverse records.
* Defined in EIP181.
* @param node The ENS node to query.
* @return The associated name.
*/
function name(
bytes32 node
) external view virtual override returns (string memory) {
return versionable_names[recordVersions[node]][node];
}

/**
* @dev Returns the node hash for a given account's reverse records.
* @param addr The address to hash
Expand Down Expand Up @@ -316,14 +364,11 @@ contract L2ReverseRegistrar is

function supportsInterface(
bytes4 interfaceID
)
public
view
override(L2NameResolver, L2TextResolver, L2ReverseResolverBase)
returns (bool)
{
) public view override(L2ReverseResolverBase) returns (bool) {
return
interfaceID == type(IL2ReverseRegistrar).interfaceId ||
interfaceID == type(ITextResolver).interfaceId ||
interfaceID == type(INameResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.4;

import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "../../resolvers/profiles/IVersionableResolver.sol";
import "../resolvers/profiles/IVersionableResolver.sol";

abstract contract L2ReverseResolverBase is ERC165 {
mapping(bytes32 => uint64) internal recordVersions;
Expand Down
40 changes: 0 additions & 40 deletions contracts/reverseRegistrar/profiles/L2NameResolver.sol

This file was deleted.

39 changes: 0 additions & 39 deletions contracts/reverseRegistrar/profiles/L2TextResolver.sol

This file was deleted.

0 comments on commit 7530428

Please sign in to comment.