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

feature(crosschain resolver): simplify reverse resolver #379

Open
wants to merge 19 commits into
base: feature/crosschain-resolver-with-reverse-registrar
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Binary file modified bun.lockb
Binary file not shown.
9 changes: 6 additions & 3 deletions contracts/resolvers/DelegatableResolver.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
pragma solidity >=0.8.4;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {Clone} from "clones-with-immutable-args/src/Clone.sol";

import "./profiles/ABIResolver.sol";
import "./profiles/AddrResolver.sol";
import "./profiles/ContentHashResolver.sol";
Expand All @@ -10,7 +14,6 @@ import "./profiles/TextResolver.sol";
import "./profiles/ExtendedResolver.sol";
import "./Multicallable.sol";
import "./IDelegatableResolver.sol";
import {Clone} from "clones-with-immutable-args/src/Clone.sol";

/**
* A delegated resolver that allows the resolver owner to add an operator to update records of a node on behalf of the owner.
Expand Down Expand Up @@ -100,7 +103,7 @@ contract DelegatableResolver is
* Returns the owner address passed set by the Factory
* @return address The owner address
*/
function owner() public view returns (address) {
function owner() public pure returns (address) {
return _getArgAddress(0);
}

Expand Down
7 changes: 5 additions & 2 deletions contracts/resolvers/DelegatableResolverFactory.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "./DelegatableResolver.sol";
import {ClonesWithImmutableArgs} from "clones-with-immutable-args/src/ClonesWithImmutableArgs.sol";

import "./DelegatableResolver.sol";

/**
* A resolver factory that creates a dedicated resolver for each user
*/
Expand Down Expand Up @@ -36,7 +37,9 @@ contract DelegatableResolverFactory {
* @param address The address of the resolver owner
* @return address The address of the newly created Resolver
*/
function predictAddress(address owner) external returns (address clone) {
function predictAddress(
address owner
) external view returns (address clone) {
bytes memory data = abi.encodePacked(owner);
clone = address(implementation).addressOfClone2(data);
}
Expand Down
53 changes: 27 additions & 26 deletions contracts/reverseRegistrar/IL2ReverseResolver.sol
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
pragma solidity >=0.8.4;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Interface for the L2 reverse resolver
interface IL2ReverseResolver {
/// @notice Thrown when the specified address is not the owner of the contract
error NotOwnerOfContract();

/// @notice Sets the `name()` record for the reverse ENS record associated with
/// the calling account.
/// @param name The name to set
/// @return The ENS node hash of the reverse record
function setName(string memory name) external returns (bytes32);

/// @notice Sets the `name()` record for the reverse ENS record associated with
/// the addr provided account.
/// Can be used if the addr is a contract that is owned by an SCA.
/// @param addr The address to set the name for
/// @param name The name to set
/// @return The ENS node hash of the reverse record
function setNameForAddr(
address addr,
string memory name
) external returns (bytes32);

/// @notice Sets the `name()` record for the reverse ENS record associated with
/// the contract provided that is owned with `Ownable`.
/// @param contractAddr The address of the contract to set the name for
/// @param owner The owner of the contract (via Ownable)
/// @param name The name to set
/// @param signatureExpiry The expiry of the signature
/// @param signature The signature of an address that will return true on isValidSignature for the owner
/// @return The ENS node hash of the reverse record
function setNameForAddrWithSignatureAndOwnable(
address contractAddr,
address owner,
string memory name,
uint256 inceptionDate,
bytes memory signature
) external returns (bytes32);

function setText(
string calldata key,
string calldata value
) external returns (bytes32);

function setTextForAddr(
address addr,
string calldata key,
string calldata value
string calldata name,
uint256 signatureExpiry,
bytes calldata signature
) external returns (bytes32);

function setTextForAddrWithSignatureAndOwnable(
address contractAddr,
address owner,
string calldata key,
string calldata value,
uint256 inceptionDate,
bytes memory signature
) external returns (bytes32);

function clearRecords(address addr) external;
}
73 changes: 70 additions & 3 deletions contracts/reverseRegistrar/IReverseRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,48 +1,115 @@
pragma solidity >=0.8.4;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Interface for the reverse registrar
interface IReverseRegistrar {
/// @notice Emitted when a reverse record is claimed.
/// @param addr The address that the reverse record is claimed for
/// @param node The ENS node hash of the reverse record
event ReverseClaimed(address indexed addr, bytes32 indexed node);

/// @notice Emitted when the default resolver is changed.
/// @param resolver The resolver that was set
event DefaultResolverChanged(address indexed resolver);

/// @notice Thrown when the caller is not authorised to perform the action
error Unauthorised();

/// @notice Thrown when the resolver address is zero
error ResolverAddressZero();

/// @notice Sets the default resolver
/// @param resolver The resolver to set
function setDefaultResolver(address resolver) external;

/// @notice Transfers ownership of the reverse ENS record associated with the
/// calling account.
/// @param owner The address to set as the owner of the reverse record in ENS.
/// @return The ENS node hash of the reverse record
function claim(address owner) external returns (bytes32);

/// @notice Transfers ownership of the reverse ENS record associated with the
/// addr provided account.
/// @param addr The address to claim the reverse record for
/// @param owner The address to set as the owner of the reverse record
/// @param resolver The resolver of the reverse node
/// @return The ENS node hash of the reverse record
function claimForAddr(
address addr,
address owner,
address resolver
) external returns (bytes32);

/// @notice Transfers ownership of the reverse ENS record associated with the
/// addr provided account using a signature to authorise.
/// @param addr The address to claim the reverse record for
/// @param owner The address to set as the owner of the reverse record
/// @param resolver The resolver of the reverse node
/// @param signatureExpiry The expiry of the signature
/// @param signature The signature to authorise the claim
/// @return The ENS node hash of the reverse record
function claimForAddrWithSignature(
address addr,
address owner,
address resolver,
address relayer,
uint256 signatureExpiry,
bytes calldata signature
) external returns (bytes32);

/// @notice Transfers ownership of the reverse ENS record associated with the
/// calling account.
/// @param owner The address to set as the owner of the reverse record
/// @param resolver The resolver of the reverse node
/// @return The ENS node hash of the reverse record
function claimWithResolver(
address owner,
address resolver
) external returns (bytes32);

/// @notice Sets the `name()` record for the reverse ENS record associated
/// with the calling account, and updates the resolver to the
/// default reverse resolver.
/// @param name The name to set for the calling account
/// @return The ENS node hash of the reverse record
function setName(string memory name) external returns (bytes32);

/// @notice Sets the `name()` record for the reverse ENS record associated
/// with the addr provided account, and updates the resolver to the
/// resolver provided.
/// @param addr The reverse record to set
/// @param owner The owner of the reverse node
/// @param resolver The resolver of the reverse node
/// @param name The name to set for the provided address
/// @return The ENS node hash of the reverse record
function setNameForAddr(
address addr,
address owner,
address resolver,
string memory name
) external returns (bytes32);

/// @notice Sets the `name()` record for the reverse ENS record associated
/// with the addr provided account using a signature to authorise,
/// and updates the resolver to the resolver provided.
/// @param addr The reverse record to set
/// @param owner The owner of the reverse node
/// @param resolver The resolver of the reverse node
/// @param signatureExpiry The expiry of the signature
/// @param signature The signature to authorise the claim
/// @param name The name to set for the provided address
/// @return The ENS node hash of the reverse record
function setNameForAddrWithSignature(
address addr,
address owner,
address resolver,
address relayer,
uint256 signatureExpiry,
bytes calldata signature,
string memory name
) external returns (bytes32);

/// @notice Returns the ENS node hash for the reverse record associated with
/// the addr provided account.
/// @param addr The address to get the reverse node hash for
/// @return The ENS node hash
function node(address addr) external pure returns (bytes32);
}
58 changes: 27 additions & 31 deletions contracts/reverseRegistrar/ISignatureReverseResolver.sol
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
pragma solidity >=0.8.4;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Interface for the signature reverse resolver
interface ISignatureReverseResolver {
event VersionChanged(bytes32 indexed node, uint64 newVersion);
event ReverseClaimed(address indexed addr, bytes32 indexed node);
event NameChanged(bytes32 indexed node, string name);
event TextChanged(
bytes32 indexed node,
string indexed indexedKey,
string key,
string value
);
/// @notice Emitted when the name of a reverse record is changed.
/// @param addr The address of the reverse record
/// @param node The ENS node hash of the reverse record
/// @param name The name of the reverse record
event NameChanged(address indexed addr, bytes32 indexed node, string name);

/// @notice Sets the `name()` record for the reverse ENS record associated with
/// the addr provided account using a signature.
/// @param addr The address to set the name for
/// @param name The name of the reverse record
/// @param signatureExpiry Date when the signature expires
/// @param signature The signature from the addr
/// @return The ENS node hash of the reverse record
function setNameForAddrWithSignature(
address addr,
string memory name,
uint256 inceptionDate,
bytes memory signature
string calldata name,
uint256 signatureExpiry,
bytes calldata signature
) external returns (bytes32);

function setTextForAddrWithSignature(
address addr,
string calldata key,
string calldata value,
uint256 inceptionDate,
bytes memory signature
) external returns (bytes32);

function clearRecordsWithSignature(
address addr,
uint256 inceptionDate,
bytes memory signature
) external;

/// @notice Returns the name associated with an ENS node hash, for reverse resolution.
/// Defined in ENSIP-3.
/// @param node The ENS node hash to query.
/// @return The associated name.
function name(bytes32 node) external view returns (string memory);

function text(
bytes32 node,
string calldata key
) external view returns (string memory);
/// @notice Returns the ENS node hash for the reverse record associated with
/// the addr provided account.
/// @param addr The address to get the reverse node hash for
/// @return The ENS node hash
function node(address addr) external view returns (bytes32);
}
Loading
Loading