Verified contractExactMIT
BoxResolver
Address0x01f2133eb313b13decaac3fee12422ec6db913aa
- Balance
0 ETH
- Transactions
26
- Compiler
solc 0.8.26
- Same code
1 more contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- paris
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,503,438
- Creation transaction
- 0x4fd6a7dd92…6eaf4f7d58
38 files
- src/BoxResolver.solmain6.06 KB
- lib/buffer/contracts/Buffer.sol8.96 KB
- lib/ens-contracts/contracts/dnssec-oracle/RRUtils.sol13.99 KB
- lib/ens-contracts/contracts/registry/ENS.sol1.82 KB
- lib/ens-contracts/contracts/resolvers/IMulticallable.sol323 B
- lib/ens-contracts/contracts/resolvers/Multicallable.sol1.73 KB
- lib/ens-contracts/contracts/resolvers/ResolverBase.sol1.07 KB
- lib/ens-contracts/contracts/resolvers/profiles/ABIResolver.sol2.14 KB
- lib/ens-contracts/contracts/resolvers/profiles/AddrResolver.sol3.83 KB
- lib/ens-contracts/contracts/resolvers/profiles/ContentHashResolver.sol1.31 KB
- lib/ens-contracts/contracts/resolvers/profiles/DNSResolver.sol7.24 KB
- lib/ens-contracts/contracts/resolvers/profiles/DataResolver.sol1.8 KB
- lib/ens-contracts/contracts/resolvers/profiles/ExtendedResolver.sol527 B
- lib/ens-contracts/contracts/resolvers/profiles/IABIResolver.sol586 B
- lib/ens-contracts/contracts/resolvers/profiles/IAddrResolver.sol411 B
- lib/ens-contracts/contracts/resolvers/profiles/IAddressResolver.sol367 B
- lib/ens-contracts/contracts/resolvers/profiles/IContentHashResolver.sol383 B
- lib/ens-contracts/contracts/resolvers/profiles/IDNSRecordResolver.sol1.01 KB
- lib/ens-contracts/contracts/resolvers/profiles/IDNSZoneResolver.sol500 B
- lib/ens-contracts/contracts/resolvers/profiles/IDataResolver.sol722 B
- lib/ens-contracts/contracts/resolvers/profiles/IExtendedResolver.sol208 B
- lib/ens-contracts/contracts/resolvers/profiles/IHasAddressResolver.sol433 B
- lib/ens-contracts/contracts/resolvers/profiles/IInterfaceResolver.sol967 B
- lib/ens-contracts/contracts/resolvers/profiles/INameResolver.sol398 B
- lib/ens-contracts/contracts/resolvers/profiles/IPubkeyResolver.sol526 B
- lib/ens-contracts/contracts/resolvers/profiles/ITextResolver.sol536 B
- lib/ens-contracts/contracts/resolvers/profiles/IVersionableResolver.sol235 B
- lib/ens-contracts/contracts/resolvers/profiles/InterfaceResolver.sol3.11 KB
- lib/ens-contracts/contracts/resolvers/profiles/NameResolver.sol1.27 KB
- lib/ens-contracts/contracts/resolvers/profiles/PubkeyResolver.sol1.7 KB
- lib/ens-contracts/contracts/resolvers/profiles/TextResolver.sol1.45 KB
- lib/ens-contracts/contracts/utils/BytesUtils.sol11.54 KB
- lib/ens-contracts/contracts/utils/ENSIP19.sol4.76 KB
- lib/ens-contracts/contracts/utils/HexUtils.sol8.29 KB
- lib/ens-contracts/contracts/utils/LibMem/LibMem.sol1.56 KB
- lib/ens-contracts/contracts/utils/NameCoder.sol13.01 KB
- lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol987 B
- lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol853 B
src/BoxResolver.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {ENS} from "ens-contracts/registry/ENS.sol";
import {Multicallable} from "ens-contracts/resolvers/Multicallable.sol";
import {ABIResolver} from "ens-contracts/resolvers/profiles/ABIResolver.sol";
import {AddrResolver} from "ens-contracts/resolvers/profiles/AddrResolver.sol";
import {ContentHashResolver} from "ens-contracts/resolvers/profiles/ContentHashResolver.sol";
import {DataResolver} from "ens-contracts/resolvers/profiles/DataResolver.sol";
import {DNSResolver} from "ens-contracts/resolvers/profiles/DNSResolver.sol";
import {InterfaceResolver} from "ens-contracts/resolvers/profiles/InterfaceResolver.sol";
import {NameResolver} from "ens-contracts/resolvers/profiles/NameResolver.sol";
import {PubkeyResolver} from "ens-contracts/resolvers/profiles/PubkeyResolver.sol";
import {TextResolver} from "ens-contracts/resolvers/profiles/TextResolver.sol";
import {ExtendedResolver} from "ens-contracts/resolvers/profiles/ExtendedResolver.sol";
import {IExtendedResolver} from "ens-contracts/resolvers/profiles/IExtendedResolver.sol";
/// @title BoxResolver
/// @notice Resolver contract for .box domains with delegation and trusted controller support
contract BoxResolver is
Multicallable,
ABIResolver,
AddrResolver,
ContentHashResolver,
DataResolver,
DNSResolver,
InterfaceResolver,
NameResolver,
PubkeyResolver,
TextResolver,
ExtendedResolver
{
///////////////////
// State variables
///////////////////
/// forge-lint: disable-next-line(screaming-snake-case-immutable)
ENS immutable ens;
/// forge-lint: disable-next-line(screaming-snake-case-immutable)
address immutable trustedBOXController;
/// forge-lint: disable-next-line(screaming-snake-case-immutable)
address immutable trustedBOXRegistry;
mapping(address => mapping(bytes32 => mapping(address => bool))) private _tokenApprovals;
///////////////////
// Events
///////////////////
/// @notice Emitted when a delegate is approved or revoked.
///
/// @param owner The owner granting or revoking approval.
/// @param node The node for which approval is granted.
/// @param delegate The delegate being approved or revoked.
/// @param approved True if approved, false if revoked.
event Approved(address owner, bytes32 indexed node, address indexed delegate, bool indexed approved);
///////////////////
// Functions
///////////////////
constructor(ENS _ens, address _trustedBoxController, address _trustedBoxRegistry) {
ens = _ens;
trustedBOXController = _trustedBoxController;
trustedBOXRegistry = _trustedBoxRegistry;
}
///////////////////
// External
///////////////////
/// @notice Approves a delegate to update records on a node.
///
/// @dev Approvals are keyed by msg.sender, not ENS ownership.
/// Only effective when msg.sender is the current ENS owner.
/// Reverts if attempting to set delegate status for self.
///
/// @param node The node to grant approval for.
/// @param delegate The address to approve or revoke.
/// @param approved True to approve, false to revoke.
function approve(bytes32 node, address delegate, bool approved) external {
require(msg.sender != delegate, "Setting delegate status for self");
_tokenApprovals[msg.sender][node][delegate] = approved;
emit Approved(msg.sender, node, delegate, approved);
}
///////////////////
// Public
///////////////////
/// @notice Clears all records for a node by incrementing the record version.
///
/// @dev Trusted controller and registry can clear without authorization.
/// Otherwise requires standard authorization. Emits `VersionChanged`.
///
/// @param node The node to clear records for.
function clearRecords(bytes32 node) public override {
if (msg.sender == trustedBOXController || msg.sender == trustedBOXRegistry) {
recordVersions[node]++;
emit VersionChanged(node, recordVersions[node]);
return;
}
super.clearRecords(node);
}
///////////////////
// External & Public View & Pure
///////////////////
/// @notice Checks if a delegate has been approved by the owner for a node.
///
/// @param owner The owner who granted approval.
/// @param node The node to check.
/// @param delegate The delegate to check.
///
/// @return True if the delegate is approved.
function isApprovedFor(address owner, bytes32 node, address delegate) public view returns (bool) {
return _tokenApprovals[owner][node][delegate];
}
/// @inheritdoc Multicallable
function supportsInterface(bytes4 interfaceId)
public
view
override(
Multicallable,
ABIResolver,
AddrResolver,
ContentHashResolver,
DataResolver,
DNSResolver,
InterfaceResolver,
NameResolver,
PubkeyResolver,
TextResolver
)
returns (bool)
{
return interfaceId == type(IExtendedResolver).interfaceId || super.supportsInterface(interfaceId);
}
///////////////////
// Internal
///////////////////
/// @notice Checks if the caller is authorized to modify records for a node.
///
/// @dev Trusted controller and registry are always authorized.
/// Otherwise checks if caller is the ENS owner or an approved delegate.
///
/// @param node The node to check authorization for.
///
/// @return True if the caller is authorized.
function isAuthorised(bytes32 node) internal view override returns (bool) {
if (msg.sender == trustedBOXController || msg.sender == trustedBOXRegistry) {
return true;
}
address owner = ens.owner(node);
return owner == msg.sender || isApprovedFor(owner, node, msg.sender);
}
}
lib/buffer/contracts/Buffer.sol
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.4;
/**
* @dev A library for working with mutable byte buffers in Solidity.
*
* Byte buffers are mutable and expandable, and provide a variety of primitives
* for appending to them. At any time you can fetch a bytes object containing the
* current contents of the buffer. The bytes object should not be stored between
* operations, as it may change due to resizing of the buffer.
*/
library Buffer {
/**
* @dev Represents a mutable buffer. Buffers have a current value (buf) and
* a capacity. The capacity may be longer than the current value, in
* which case it can be extended without the need to allocate more memory.
*/
struct buffer {
bytes buf;
uint capacity;
}
/**
* @dev Initializes a buffer with an initial capacity.
* @param buf The buffer to initialize.
* @param capacity The number of bytes of space to allocate the buffer.
* @return The buffer, for chaining.
*/
function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {
if (capacity % 32 != 0) {
capacity += 32 - (capacity % 32);
}
// Allocate space for the buffer data
buf.capacity = capacity;
assembly {
let ptr := mload(0x40)
mstore(buf, ptr)
mstore(ptr, 0)
let fpm := add(32, add(ptr, capacity))
if lt(fpm, ptr) {
revert(0, 0)
}
mstore(0x40, fpm)
}
return buf;
}
/**
* @dev Initializes a new buffer from an existing bytes object.
* Changes to the buffer may mutate the original value.
* @param b The bytes object to initialize the buffer with.
* @return A new buffer.
*/
function fromBytes(bytes memory b) internal pure returns(buffer memory) {
buffer memory buf;
buf.buf = b;
buf.capacity = b.length;
return buf;
}
function resize(buffer memory buf, uint capacity) private pure {
bytes memory oldbuf = buf.buf;
init(buf, capacity);
append(buf, oldbuf);
}
/**
* @dev Sets buffer length to 0.
* @param buf The buffer to truncate.
* @return The original buffer, for chaining..
*/
function truncate(buffer memory buf) internal pure returns (buffer memory) {
assembly {
let bufptr := mload(buf)
mstore(bufptr, 0)
}
return buf;
}
/**
* @dev Appends len bytes of a byte string to a buffer. Resizes if doing so would exceed
* the capacity of the buffer.
* @param buf The buffer to append to.
* @param data The data to append.
* @param len The number of bytes to copy.
* @return The original buffer, for chaining.
*/
function append(buffer memory buf, bytes memory data, uint len) internal pure returns(buffer memory) {
require(len <= data.length);
uint off = buf.buf.length;
uint newCapacity = off + len;
if (newCapacity > buf.capacity) {
resize(buf, newCapacity * 2);
}
uint dest;
uint src;
assembly {
// Memory address of the buffer data
let bufptr := mload(buf)
// Length of existing buffer data
let buflen := mload(bufptr)
// Start address = buffer address + offset + sizeof(buffer length)
dest := add(add(bufptr, 32), off)
// Update buffer length if we're extending it
if gt(newCapacity, buflen) {
mstore(bufptr, newCapacity)
}
src := add(data, 32)
}
// Copy word-length chunks while possible
for (; len >= 32; len -= 32) {
assembly {
mstore(dest, mload(src))
}
dest += 32;
src += 32;
}
// Copy remaining bytes
unchecked {
uint mask = (256 ** (32 - len)) - 1;
assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
}
}
return buf;
}
/**
* @dev Appends a byte string to a buffer. Resizes if doing so would exceed
* the capacity of the buffer.
* @param buf The buffer to append to.
* @param data The data to append.
* @return The original buffer, for chaining.
*/
function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {
return append(buf, data, data.length);
}
/**
* @dev Appends a byte to the buffer. Resizes if doing so would exceed the
* capacity of the buffer.
* @param buf The buffer to append to.
* @param data The data to append.
* @return The original buffer, for chaining.
*/
function appendUint8(buffer memory buf, uint8 data) internal pure returns(buffer memory) {
uint off = buf.buf.length;
uint offPlusOne = off + 1;
if (off >= buf.capacity) {
resize(buf, offPlusOne * 2);
}
assembly {
// Memory address of the buffer data
let bufptr := mload(buf)
// Address = buffer address + sizeof(buffer length) + off
let dest := add(add(bufptr, off), 32)
mstore8(dest, data)
// Update buffer length if we extended it
if gt(offPlusOne, mload(bufptr)) {
mstore(bufptr, offPlusOne)
}
}
return buf;
}
/**
* @dev Appends len bytes of bytes32 to a buffer. Resizes if doing so would
* exceed the capacity of the buffer.
* @param buf The buffer to append to.
* @param data The data to append.
* @param len The number of bytes to write (left-aligned).
* @return The original buffer, for chaining.
*/
function append(buffer memory buf, bytes32 data, uint len) private pure returns(buffer memory) {
uint off = buf.buf.length;
uint newCapacity = len + off;
if (newCapacity > buf.capacity) {
resize(buf, newCapacity * 2);
}
unchecked {
uint mask = (256 ** len) - 1;
// Right-align data
data = data >> (8 * (32 - len));
assembly {
// Memory address of the buffer data
let bufptr := mload(buf)
// Address = buffer address + sizeof(buffer length) + newCapacity
let dest := add(bufptr, newCapacity)
mstore(dest, or(and(mload(dest), not(mask)), data))
// Update buffer length if we extended it
if gt(newCapacity, mload(bufptr)) {
mstore(bufptr, newCapacity)
}
}
}
return buf;
}
/**
* @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed
* the capacity of the buffer.
* @param buf The buffer to append to.
* @param data The data to append.
* @return The original buffer, for chhaining.
*/
function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {
return append(buf, bytes32(data), 20);
}
/**
* @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed
* the capacity of the buffer.
* @param buf The buffer to append to.
* @param data The data to append.
* @return The original buffer, for chaining.
*/
function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {
return append(buf, data, 32);
}
/**
* @dev Appends a byte to the end of the buffer. Resizes if doing so would
* exceed the capacity of the buffer.
* @param buf The buffer to append to.
* @param data The data to append.
* @param len The number of bytes to write (right-aligned).
* @return The original buffer.
*/
function appendInt(buffer memory buf, uint data, uint len) internal pure returns(buffer memory) {
uint off = buf.buf.length;
uint newCapacity = len + off;
if (newCapacity > buf.capacity) {
resize(buf, newCapacity * 2);
}
unchecked {
uint mask = (256 ** len) - 1;
assembly {
// Memory address of the buffer data
let bufptr := mload(buf)
// Address = buffer address + sizeof(buffer length) + newCapacity
let dest := add(bufptr, newCapacity)
mstore(dest, or(and(mload(dest), not(mask)), data))
// Update buffer length if we extended it
if gt(newCapacity, mload(bufptr)) {
mstore(bufptr, newCapacity)
}
}
}
return buf;
}
}
lib/ens-contracts/contracts/dnssec-oracle/RRUtils.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "../utils/BytesUtils.sol";
import "@ensdomains/buffer/contracts/Buffer.sol";
/// @dev RRUtils is a library that provides utilities for parsing DNS resource records.
library RRUtils {
using BytesUtils for *;
using Buffer for *;
/// @dev Returns the number of bytes in the DNS name at 'offset' in 'self'.
/// @param self The byte array to read a name from.
/// @param offset The offset to start reading at.
/// @return The length of the DNS name at 'offset', in bytes.
function nameLength(
bytes memory self,
uint256 offset
) internal pure returns (uint256) {
uint256 idx = offset;
while (true) {
assert(idx < self.length);
uint256 labelLen = self.readUint8(idx);
idx += labelLen + 1;
if (labelLen == 0) {
break;
}
}
return idx - offset;
}
/// @dev Returns a DNS format name at the specified offset of self.
/// @param self The byte array to read a name from.
/// @param offset The offset to start reading at.
/// @return ret The name.
function readName(
bytes memory self,
uint256 offset
) internal pure returns (bytes memory ret) {
uint256 len = nameLength(self, offset);
return self.substring(offset, len);
}
/// @dev Returns the number of labels in the DNS name at 'offset' in 'self'.
/// @param self The byte array to read a name from.
/// @param offset The offset to start reading at.
/// @return The number of labels in the DNS name at 'offset', in bytes.
function labelCount(
bytes memory self,
uint256 offset
) internal pure returns (uint256) {
uint256 count = 0;
while (true) {
assert(offset < self.length);
uint256 labelLen = self.readUint8(offset);
offset += labelLen + 1;
if (labelLen == 0) {
break;
}
count += 1;
}
return count;
}
uint256 constant RRSIG_TYPE = 0;
uint256 constant RRSIG_ALGORITHM = 2;
uint256 constant RRSIG_LABELS = 3;
uint256 constant RRSIG_TTL = 4;
uint256 constant RRSIG_EXPIRATION = 8;
uint256 constant RRSIG_INCEPTION = 12;
uint256 constant RRSIG_KEY_TAG = 16;
uint256 constant RRSIG_SIGNER_NAME = 18;
struct SignedSet {
uint16 typeCovered;
uint8 algorithm;
uint8 labels;
uint32 ttl;
uint32 expiration;
uint32 inception;
uint16 keytag;
bytes signerName;
bytes data;
bytes name;
}
function readSignedSet(
bytes memory data
) internal pure returns (SignedSet memory self) {
self.typeCovered = data.readUint16(RRSIG_TYPE);
self.algorithm = data.readUint8(RRSIG_ALGORITHM);
self.labels = data.readUint8(RRSIG_LABELS);
self.ttl = data.readUint32(RRSIG_TTL);
self.expiration = data.readUint32(RRSIG_EXPIRATION);
self.inception = data.readUint32(RRSIG_INCEPTION);
self.keytag = data.readUint16(RRSIG_KEY_TAG);
self.signerName = readName(data, RRSIG_SIGNER_NAME);
self.data = data.substring(
RRSIG_SIGNER_NAME + self.signerName.length,
data.length - RRSIG_SIGNER_NAME - self.signerName.length
);
}
function rrs(
SignedSet memory rrset
) internal pure returns (RRIterator memory) {
return iterateRRs(rrset.data, 0);
}
/// @dev An iterator over resource records.
struct RRIterator {
bytes data;
uint256 offset;
uint16 dnstype;
uint16 class;
uint32 ttl;
uint256 rdataOffset;
uint256 nextOffset;
}
/// @dev Begins iterating over resource records.
/// @param self The byte string to read from.
/// @param offset The offset to start reading at.
/// @return ret An iterator object.
function iterateRRs(
bytes memory self,
uint256 offset
) internal pure returns (RRIterator memory ret) {
ret.data = self;
ret.nextOffset = offset;
next(ret);
}
/// @dev Returns true iff there are more RRs to iterate.
/// @param iter The iterator to check.
/// @return True iff the iterator has finished.
function done(RRIterator memory iter) internal pure returns (bool) {
return iter.offset >= iter.data.length;
}
/// @dev Moves the iterator to the next resource record.
/// @param iter The iterator to advance.
function next(RRIterator memory iter) internal pure {
iter.offset = iter.nextOffset;
if (iter.offset >= iter.data.length) {
return;
}
// Skip the name
uint256 off = iter.offset + nameLength(iter.data, iter.offset);
// Read type, class, and ttl
iter.dnstype = iter.data.readUint16(off);
off += 2;
iter.class = iter.data.readUint16(off);
off += 2;
iter.ttl = iter.data.readUint32(off);
off += 4;
// Read the rdata
uint256 rdataLength = iter.data.readUint16(off);
off += 2;
iter.rdataOffset = off;
iter.nextOffset = off + rdataLength;
}
/// @dev Returns the name of the current record.
/// @param iter The iterator.
/// @return A new bytes object containing the owner name from the RR.
function name(RRIterator memory iter) internal pure returns (bytes memory) {
return
iter.data.substring(
iter.offset,
nameLength(iter.data, iter.offset)
);
}
/// @dev Returns the rdata portion of the current record.
/// @param iter The iterator.
/// @return A new bytes object containing the RR's RDATA.
function rdata(
RRIterator memory iter
) internal pure returns (bytes memory) {
return
iter.data.substring(
iter.rdataOffset,
iter.nextOffset - iter.rdataOffset
);
}
uint256 constant DNSKEY_FLAGS = 0;
uint256 constant DNSKEY_PROTOCOL = 2;
uint256 constant DNSKEY_ALGORITHM = 3;
uint256 constant DNSKEY_PUBKEY = 4;
struct DNSKEY {
uint16 flags;
uint8 protocol;
uint8 algorithm;
bytes publicKey;
}
function readDNSKEY(
bytes memory data,
uint256 offset,
uint256 length
) internal pure returns (DNSKEY memory self) {
self.flags = data.readUint16(offset + DNSKEY_FLAGS);
self.protocol = data.readUint8(offset + DNSKEY_PROTOCOL);
self.algorithm = data.readUint8(offset + DNSKEY_ALGORITHM);
self.publicKey = data.substring(
offset + DNSKEY_PUBKEY,
length - DNSKEY_PUBKEY
);
}
uint256 constant DS_KEY_TAG = 0;
uint256 constant DS_ALGORITHM = 2;
uint256 constant DS_DIGEST_TYPE = 3;
uint256 constant DS_DIGEST = 4;
struct DS {
uint16 keytag;
uint8 algorithm;
uint8 digestType;
bytes digest;
}
function readDS(
bytes memory data,
uint256 offset,
uint256 length
) internal pure returns (DS memory self) {
self.keytag = data.readUint16(offset + DS_KEY_TAG);
self.algorithm = data.readUint8(offset + DS_ALGORITHM);
self.digestType = data.readUint8(offset + DS_DIGEST_TYPE);
self.digest = data.substring(offset + DS_DIGEST, length - DS_DIGEST);
}
function isSubdomainOf(
bytes memory self,
bytes memory other
) internal pure returns (bool) {
uint256 off = 0;
uint256 counts = labelCount(self, 0);
uint256 othercounts = labelCount(other, 0);
while (counts > othercounts) {
off = progress(self, off);
counts--;
}
return self.equals(off, other, 0);
}
function compareNames(
bytes memory self,
bytes memory other
) internal pure returns (int256) {
if (self.equals(other)) {
return 0;
}
uint256 off;
uint256 otheroff;
uint256 prevoff;
uint256 otherprevoff;
uint256 counts = labelCount(self, 0);
uint256 othercounts = labelCount(other, 0);
// Keep removing labels from the front of the name until both names are equal length
while (counts > othercounts) {
prevoff = off;
off = progress(self, off);
counts--;
}
while (othercounts > counts) {
otherprevoff = otheroff;
otheroff = progress(other, otheroff);
othercounts--;
}
// Compare the last nonequal labels to each other
while (counts > 0 && !self.equals(off, other, otheroff)) {
prevoff = off;
off = progress(self, off);
otherprevoff = otheroff;
otheroff = progress(other, otheroff);
counts -= 1;
}
if (off == 0) {
return -1;
}
if (otheroff == 0) {
return 1;
}
return
self.compare(
prevoff + 1,
self.readUint8(prevoff),
other,
otherprevoff + 1,
other.readUint8(otherprevoff)
);
}
/// @dev Compares two serial numbers using RFC1982 serial number math.
function serialNumberGte(
uint32 i1,
uint32 i2
) internal pure returns (bool) {
unchecked {
return int32(i1) - int32(i2) >= 0;
}
}
function progress(
bytes memory body,
uint256 off
) internal pure returns (uint256) {
return off + 1 + body.readUint8(off);
}
/// @dev Computes the keytag for a chunk of data.
/// @param data The data to compute a keytag for.
/// @return The computed key tag.
function computeKeytag(bytes memory data) internal pure returns (uint16) {
/* This function probably deserves some explanation.
* The DNSSEC keytag function is a checksum that relies on summing up individual bytes
* from the input string, with some mild bitshifting. Here's a Naive solidity implementation:
*
* function computeKeytag(bytes memory data) internal pure returns (uint16) {
* uint ac;
* for (uint i = 0; i < data.length; i++) {
* ac += i & 1 == 0 ? uint16(data.readUint8(i)) << 8 : data.readUint8(i);
* }
* return uint16(ac + (ac >> 16));
* }
*
* The EVM, with its 256 bit words, is exceedingly inefficient at doing byte-by-byte operations;
* the code above, on reasonable length inputs, consumes over 100k gas. But we can make the EVM's
* large words work in our favour.
*
* The code below works by treating the input as a series of 256 bit words. It first masks out
* even and odd bytes from each input word, adding them to two separate accumulators `ac1` and `ac2`.
* The bytes are separated by empty bytes, so as long as no individual sum exceeds 2^16-1, we're
* effectively summing 16 different numbers with each EVM ADD opcode.
*
* Once it's added up all the inputs, it has to add all the 16 bit values in `ac1` and `ac2` together.
* It does this using the same trick - mask out every other value, shift to align them, add them together.
* After the first addition on both accumulators, there's enough room to add the two accumulators together,
* and the remaining sums can be done just on ac1.
*/
unchecked {
require(data.length <= 8192, "Long keys not permitted");
uint256 ac1;
uint256 ac2;
for (uint256 i = 0; i < data.length + 31; i += 32) {
uint256 word;
assembly {
word := mload(add(add(data, 32), i))
}
if (i + 32 > data.length) {
uint256 unused = 256 - (data.length - i) * 8;
word = (word >> unused) << unused;
}
ac1 +=
(word &
0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00) >>
8;
ac2 += (word &
0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF);
}
ac1 =
(ac1 &
0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) +
((ac1 &
0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000) >>
16);
ac2 =
(ac2 &
0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) +
((ac2 &
0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000) >>
16);
ac1 = (ac1 << 8) + ac2;
ac1 =
(ac1 &
0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) +
((ac1 &
0xFFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000) >>
32);
ac1 =
(ac1 &
0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) +
((ac1 &
0xFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF0000000000000000) >>
64);
ac1 =
(ac1 &
0x00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) +
(ac1 >> 128);
ac1 += (ac1 >> 16) & 0xFFFF;
return uint16(ac1);
}
}
}
lib/ens-contracts/contracts/registry/ENS.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface ENS {
// Logged when the owner of a node assigns a new owner to a subnode.
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
// Logged when the owner of a node transfers ownership to a new account.
event Transfer(bytes32 indexed node, address owner);
// Logged when the resolver for a node changes.
event NewResolver(bytes32 indexed node, address resolver);
// Logged when the TTL of a node changes
event NewTTL(bytes32 indexed node, uint64 ttl);
// Logged when an operator is added or removed.
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
function setRecord(
bytes32 node,
address owner,
address resolver,
uint64 ttl
) external;
function setSubnodeRecord(
bytes32 node,
bytes32 label,
address owner,
address resolver,
uint64 ttl
) external;
function setSubnodeOwner(
bytes32 node,
bytes32 label,
address owner
) external returns (bytes32);
function setResolver(bytes32 node, address resolver) external;
function setOwner(bytes32 node, address owner) external;
function setTTL(bytes32 node, uint64 ttl) external;
function setApprovalForAll(address operator, bool approved) external;
function owner(bytes32 node) external view returns (address);
function resolver(bytes32 node) external view returns (address);
function ttl(bytes32 node) external view returns (uint64);
function recordExists(bytes32 node) external view returns (bool);
function isApprovedForAll(
address owner,
address operator
) external view returns (bool);
}
lib/ens-contracts/contracts/resolvers/IMulticallable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IMulticallable {
function multicall(
bytes[] calldata data
) external returns (bytes[] memory results);
function multicallWithNodeCheck(
bytes32,
bytes[] calldata data
) external returns (bytes[] memory results);
}
lib/ens-contracts/contracts/resolvers/Multicallable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "./IMulticallable.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
abstract contract Multicallable is IMulticallable, ERC165 {
function _multicall(
bytes32 nodehash,
bytes[] calldata data
) internal returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
if (nodehash != bytes32(0)) {
bytes32 txNamehash = bytes32(data[i][4:36]);
require(
txNamehash == nodehash,
"multicall: All records must have a matching namehash"
);
}
(bool success, bytes memory result) = address(this).delegatecall(
data[i]
);
require(success);
results[i] = result;
}
return results;
}
// This function provides an extra security check when called
// from privileged contracts (such as EthRegistrarController)
// that can set records on behalf of the node owners
function multicallWithNodeCheck(
bytes32 nodehash,
bytes[] calldata data
) external returns (bytes[] memory results) {
return _multicall(nodehash, data);
}
function multicall(
bytes[] calldata data
) public override returns (bytes[] memory results) {
return _multicall(bytes32(0), data);
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IMulticallable).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/ResolverBase.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "./profiles/IVersionableResolver.sol";
abstract contract ResolverBase is ERC165, IVersionableResolver {
mapping(bytes32 => uint64) public recordVersions;
function isAuthorised(bytes32 node) internal view virtual returns (bool);
modifier authorised(bytes32 node) {
require(isAuthorised(node));
_;
}
/// Increments the record version associated with an ENS node.
/// May only be called by the owner of that node in the ENS registry.
/// @param node The node to update.
function clearRecords(bytes32 node) public virtual authorised(node) {
recordVersions[node]++;
emit VersionChanged(node, recordVersions[node]);
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IVersionableResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/profiles/ABIResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "./IABIResolver.sol";
import "../ResolverBase.sol";
abstract contract ABIResolver is IABIResolver, ResolverBase {
mapping(uint64 => mapping(bytes32 => mapping(uint256 => bytes))) versionable_abis;
/// Sets the ABI associated with an ENS node.
/// Nodes may have one ABI of each content type. To remove an ABI, set it to
/// the empty string.
/// @param node The node to update.
/// @param contentType The content type of the ABI
/// @param data The ABI data.
function setABI(
bytes32 node,
uint256 contentType,
bytes calldata data
) external virtual authorised(node) {
// Content types must be powers of 2
require(((contentType - 1) & contentType) == 0);
versionable_abis[recordVersions[node]][node][contentType] = data;
emit ABIChanged(node, contentType);
}
/// Returns the ABI associated with an ENS node.
/// Defined in EIP205.
/// @param node The ENS node to query
/// @param contentTypes A bitwise OR of the ABI formats accepted by the caller.
/// @return contentType The content type of the return value
/// @return data The ABI data
function ABI(
bytes32 node,
uint256 contentTypes
) external view virtual override returns (uint256, bytes memory) {
mapping(uint256 => bytes) storage abiset = versionable_abis[
recordVersions[node]
][node];
for (
uint256 contentType = 1;
contentType > 0 && contentType <= contentTypes;
contentType <<= 1
) {
if (
(contentType & contentTypes) != 0 &&
abiset[contentType].length > 0
) {
return (contentType, abiset[contentType]);
}
}
return (0, bytes(""));
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IABIResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/profiles/AddrResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import {ResolverBase, IERC165} from "../ResolverBase.sol";
import {IAddrResolver} from "./IAddrResolver.sol";
import {IAddressResolver} from "./IAddressResolver.sol";
import {IHasAddressResolver} from "./IHasAddressResolver.sol";
import {ENSIP19, COIN_TYPE_ETH, COIN_TYPE_DEFAULT} from "../../utils/ENSIP19.sol";
abstract contract AddrResolver is
IAddrResolver,
IAddressResolver,
IHasAddressResolver,
ResolverBase
{
mapping(uint64 => mapping(bytes32 => mapping(uint256 => bytes))) versionable_addresses;
/// @notice The supplied address could not be converted to `address`.
/// @dev Error selector: `0x8d666f60`
error InvalidEVMAddress(bytes addressBytes);
/// @notice Set `addr(60)` of the associated ENS node.
/// `address(0)` is stored as `new bytes(20)`.
/// @param node The node to update.
/// @param _addr The address to set.
function setAddr(
bytes32 node,
address _addr
) external virtual authorised(node) {
setAddr(node, COIN_TYPE_ETH, abi.encodePacked(_addr));
}
/// @notice Get `addr(60)` as `address` of the associated ENS node.
/// @param node The node to query.
/// @return The associated address.
function addr(
bytes32 node
) public view virtual override returns (address payable) {
return payable(address(bytes20(addr(node, COIN_TYPE_ETH))));
}
/// @notice Set the address for coin type of the associated ENS node.
/// Reverts `InvalidEVMAddress` if coin type is EVM and not 0 or 20 bytes.
/// @param node The node to update.
/// @param coinType The coin type.
/// @param addressBytes The address to set.
function setAddr(
bytes32 node,
uint256 coinType,
bytes memory addressBytes
) public virtual authorised(node) {
if (
addressBytes.length != 0 &&
addressBytes.length != 20 &&
ENSIP19.isEVMCoinType(coinType)
) {
revert InvalidEVMAddress(addressBytes);
}
emit AddressChanged(node, coinType, addressBytes);
if (coinType == COIN_TYPE_ETH) {
emit AddrChanged(node, address(bytes20(addressBytes)));
}
versionable_addresses[recordVersions[node]][node][
coinType
] = addressBytes;
}
/// @notice Get the address for coin type of the associated ENS node.
/// If coin type is EVM and empty, defaults to `addr(COIN_TYPE_DEFAULT)`.
/// @param node The node to query.
/// @param coinType The coin type.
/// @return addressBytes The assocated address.
function addr(
bytes32 node,
uint256 coinType
) public view virtual override returns (bytes memory addressBytes) {
mapping(uint256 => bytes) storage addrs = versionable_addresses[
recordVersions[node]
][node];
addressBytes = addrs[coinType];
if (
addressBytes.length == 0 && ENSIP19.chainFromCoinType(coinType) > 0
) {
addressBytes = addrs[COIN_TYPE_DEFAULT];
}
}
/// @inheritdoc IHasAddressResolver
function hasAddr(
bytes32 node,
uint256 coinType
) external view returns (bool) {
return
versionable_addresses[recordVersions[node]][node][coinType].length >
0;
}
/// @inheritdoc IERC165
function supportsInterface(
bytes4 interfaceId
) public view virtual override returns (bool) {
return
type(IAddrResolver).interfaceId == interfaceId ||
type(IAddressResolver).interfaceId == interfaceId ||
type(IHasAddressResolver).interfaceId == interfaceId ||
super.supportsInterface(interfaceId);
}
}
lib/ens-contracts/contracts/resolvers/profiles/ContentHashResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "../ResolverBase.sol";
import "./IContentHashResolver.sol";
abstract contract ContentHashResolver is IContentHashResolver, ResolverBase {
mapping(uint64 => mapping(bytes32 => bytes)) versionable_hashes;
/// Sets the contenthash associated with an ENS node.
/// May only be called by the owner of that node in the ENS registry.
/// @param node The node to update.
/// @param hash The contenthash to set
function setContenthash(
bytes32 node,
bytes calldata hash
) external virtual authorised(node) {
versionable_hashes[recordVersions[node]][node] = hash;
emit ContenthashChanged(node, hash);
}
/// Returns the contenthash associated with an ENS node.
/// @param node The ENS node to query.
/// @return The associated contenthash.
function contenthash(
bytes32 node
) external view virtual override returns (bytes memory) {
return versionable_hashes[recordVersions[node]][node];
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IContentHashResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/profiles/DNSResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "../ResolverBase.sol";
import "../../dnssec-oracle/RRUtils.sol";
import "./IDNSRecordResolver.sol";
import "./IDNSZoneResolver.sol";
abstract contract DNSResolver is
IDNSRecordResolver,
IDNSZoneResolver,
ResolverBase
{
using RRUtils for *;
using BytesUtils for bytes;
// Zone hashes for the domains.
// A zone hash is an EIP-1577 content hash in binary format that should point to a
// resource containing a single zonefile.
// node => contenthash
mapping(uint64 => mapping(bytes32 => bytes)) private versionable_zonehashes;
// The records themselves. Stored as binary RRSETs
// node => version => name => resource => data
mapping(uint64 => mapping(bytes32 => mapping(bytes32 => mapping(uint16 => bytes))))
private versionable_records;
// Count of number of entries for a given name. Required for DNS resolvers
// when resolving wildcards.
// node => version => name => number of records
mapping(uint64 => mapping(bytes32 => mapping(bytes32 => uint16)))
private versionable_nameEntriesCount;
/// Set one or more DNS records. Records are supplied in wire-format.
/// Records with the same node/name/resource must be supplied one after the
/// other to ensure the data is updated correctly. For example, if the data
/// was supplied:
/// a.example.com IN A 1.2.3.4
/// a.example.com IN A 5.6.7.8
/// www.example.com IN CNAME a.example.com.
/// then this would store the two A records for a.example.com correctly as a
/// single RRSET, however if the data was supplied:
/// a.example.com IN A 1.2.3.4
/// www.example.com IN CNAME a.example.com.
/// a.example.com IN A 5.6.7.8
/// then this would store the first A record, the CNAME, then the second A
/// record which would overwrite the first.
///
/// @param node the namehash of the node for which to set the records
/// @param data the DNS wire format records to set
function setDNSRecords(
bytes32 node,
bytes calldata data
) external virtual authorised(node) {
uint16 resource = 0;
uint256 offset = 0;
bytes memory name;
bytes memory value;
bytes32 nameHash;
uint64 version = recordVersions[node];
// Iterate over the data to add the resource records
for (
RRUtils.RRIterator memory iter = data.iterateRRs(0);
!iter.done();
iter.next()
) {
if (resource == 0) {
resource = iter.dnstype;
name = iter.name();
nameHash = keccak256(abi.encodePacked(name));
value = bytes(iter.rdata());
} else {
bytes memory newName = iter.name();
if (resource != iter.dnstype || !name.equals(newName)) {
setDNSRRSet(
node,
name,
resource,
data,
offset,
iter.offset - offset,
value.length == 0,
version
);
resource = iter.dnstype;
offset = iter.offset;
name = newName;
nameHash = keccak256(name);
value = bytes(iter.rdata());
}
}
}
if (name.length > 0) {
setDNSRRSet(
node,
name,
resource,
data,
offset,
data.length - offset,
value.length == 0,
version
);
}
}
/// Obtain a DNS record.
/// @param node the namehash of the node for which to fetch the record
/// @param name the keccak-256 hash of the fully-qualified name for which to fetch the record
/// @param resource the ID of the resource as per https://en.wikipedia.org/wiki/List_of_DNS_record_types
/// @return the DNS record in wire format if present, otherwise empty
function dnsRecord(
bytes32 node,
bytes32 name,
uint16 resource
) public view virtual override returns (bytes memory) {
return versionable_records[recordVersions[node]][node][name][resource];
}
/// Check if a given node has records.
/// @param node the namehash of the node for which to check the records
/// @param name the namehash of the node for which to check the records
function hasDNSRecords(
bytes32 node,
bytes32 name
) public view virtual returns (bool) {
return (versionable_nameEntriesCount[recordVersions[node]][node][
name
] != 0);
}
/// setZonehash sets the hash for the zone.
/// May only be called by the owner of that node in the ENS registry.
/// @param node The node to update.
/// @param hash The zonehash to set
function setZonehash(
bytes32 node,
bytes calldata hash
) external virtual authorised(node) {
uint64 currentRecordVersion = recordVersions[node];
bytes memory oldhash = versionable_zonehashes[currentRecordVersion][
node
];
versionable_zonehashes[currentRecordVersion][node] = hash;
emit DNSZonehashChanged(node, oldhash, hash);
}
/// zonehash obtains the hash for the zone.
/// @param node The ENS node to query.
/// @return The associated contenthash.
function zonehash(
bytes32 node
) external view virtual override returns (bytes memory) {
return versionable_zonehashes[recordVersions[node]][node];
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IDNSRecordResolver).interfaceId ||
interfaceID == type(IDNSZoneResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
function setDNSRRSet(
bytes32 node,
bytes memory name,
uint16 resource,
bytes memory data,
uint256 offset,
uint256 size,
bool deleteRecord,
uint64 version
) private {
bytes32 nameHash = keccak256(name);
bytes memory rrData = data.substring(offset, size);
if (deleteRecord) {
if (
versionable_records[version][node][nameHash][resource].length !=
0
) {
versionable_nameEntriesCount[version][node][nameHash]--;
}
delete (versionable_records[version][node][nameHash][resource]);
emit DNSRecordDeleted(node, name, resource);
} else {
if (
versionable_records[version][node][nameHash][resource].length ==
0
) {
versionable_nameEntriesCount[version][node][nameHash]++;
}
versionable_records[version][node][nameHash][resource] = rrData;
emit DNSRecordChanged(node, name, resource, rrData);
}
}
}
lib/ens-contracts/contracts/resolvers/profiles/DataResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "../ResolverBase.sol";
import "./IDataResolver.sol";
abstract contract DataResolver is
IDataResolver,
ResolverBase
{
mapping(uint64 => mapping(bytes32 node => mapping(string key => bytes data)))
private versionable_dataStore;
/// @notice Sets the data associated with the key, `key` for a specific `node`.
/// May only be called by the owner of that node in the ENS registry.
/// @param node The node to update.
/// @param key The key to set.
/// @param value The arbitrary `bytes` data to set.
function setData(
bytes32 node,
string calldata key,
bytes calldata value
) external virtual authorised(node) {
versionable_dataStore[recordVersions[node]][node][key] = value;
_afterSetData(node, key, value);
emit DataChanged(node, key, key, value);
}
/// @dev Hook called after data is set. Override to add custom behavior.
function _afterSetData(
bytes32 node,
string memory key,
bytes memory value
) internal virtual {}
/// @notice For a specific `node`, get the data associated with the key, `key`.
/// @param node The node (namehash) for which data is being fetched.
/// @param key The key.
/// @return The associated arbitrary `bytes` data.
function data(
bytes32 node,
string calldata key
) external view returns (bytes memory) {
return versionable_dataStore[recordVersions[node]][node][key];
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IDataResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/profiles/ExtendedResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract ExtendedResolver {
function resolve(
bytes memory /* name */,
bytes memory data
) external view returns (bytes memory) {
(bool success, bytes memory result) = address(this).staticcall(data);
if (success) {
return result;
} else {
// Revert with the reason provided by the call
assembly {
revert(add(result, 0x20), mload(result))
}
}
}
}
lib/ens-contracts/contracts/resolvers/profiles/IABIResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IABIResolver {
event ABIChanged(bytes32 indexed node, uint256 indexed contentType);
/// Returns the ABI associated with an ENS node.
/// Defined in EIP205.
/// @param node The ENS node to query
/// @param contentTypes A bitwise OR of the ABI formats accepted by the caller.
/// @return contentType The content type of the return value
/// @return data The ABI data
function ABI(
bytes32 node,
uint256 contentTypes
) external view returns (uint256, bytes memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IAddrResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
/// Interface for the legacy (ETH-only) addr function.
interface IAddrResolver {
event AddrChanged(bytes32 indexed node, address a);
/// Returns the address associated with an ENS node.
/// @param node The ENS node to query.
/// @return The associated address.
function addr(bytes32 node) external view returns (address payable);
}
lib/ens-contracts/contracts/resolvers/profiles/IAddressResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
/// Interface for the new (multicoin) addr function.
interface IAddressResolver {
event AddressChanged(
bytes32 indexed node,
uint256 coinType,
bytes newAddress
);
function addr(
bytes32 node,
uint256 coinType
) external view returns (bytes memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IContentHashResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IContentHashResolver {
event ContenthashChanged(bytes32 indexed node, bytes hash);
/// Returns the contenthash associated with an ENS node.
/// @param node The ENS node to query.
/// @return The associated contenthash.
function contenthash(bytes32 node) external view returns (bytes memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IDNSRecordResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IDNSRecordResolver {
// DNSRecordChanged is emitted whenever a given node/name/resource's RRSET is updated.
event DNSRecordChanged(
bytes32 indexed node,
bytes name,
uint16 resource,
bytes record
);
// DNSRecordDeleted is emitted whenever a given node/name/resource's RRSET is deleted.
event DNSRecordDeleted(bytes32 indexed node, bytes name, uint16 resource);
/// Obtain a DNS record.
/// @param node the namehash of the node for which to fetch the record
/// @param name the keccak-256 hash of the fully-qualified name for which to fetch the record
/// @param resource the ID of the resource as per https://en.wikipedia.org/wiki/List_of_DNS_record_types
/// @return the DNS record in wire format if present, otherwise empty
function dnsRecord(
bytes32 node,
bytes32 name,
uint16 resource
) external view returns (bytes memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IDNSZoneResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IDNSZoneResolver {
// DNSZonehashChanged is emitted whenever a given node's zone hash is updated.
event DNSZonehashChanged(
bytes32 indexed node,
bytes lastzonehash,
bytes zonehash
);
/// zonehash obtains the hash for the zone.
/// @param node The ENS node to query.
/// @return The associated contenthash.
function zonehash(bytes32 node) external view returns (bytes memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IDataResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
/// @dev Interface selector: `0xecbfada3`
interface IDataResolver {
/// @notice For a specific `node`, the data associated with a `key` has changed.
event DataChanged(
bytes32 indexed node,
string indexed indexedKey,
string key,
bytes indexed indexedData
);
/// @notice For a specific `node`, get the data associated with the key, `key`.
/// @param node The node (namehash) for which data is being fetched.
/// @param key The key.
/// @return The associated arbitrary `bytes` data.
function data(
bytes32 node,
string calldata key
) external view returns (bytes memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IExtendedResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IExtendedResolver {
function resolve(
bytes memory name,
bytes memory data
) external view returns (bytes memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IHasAddressResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IHasAddressResolver {
/// @notice Determine if an addresss is stored for the coin type of the associated ENS node.
/// @param node The node to query.
/// @param coinType The coin type.
/// @return True if the associated address is not empty.
function hasAddr(
bytes32 node,
uint256 coinType
) external view returns (bool);
}
lib/ens-contracts/contracts/resolvers/profiles/IInterfaceResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IInterfaceResolver {
event InterfaceChanged(
bytes32 indexed node,
bytes4 indexed interfaceID,
address implementer
);
/// Returns the address of a contract that implements the specified interface for this name.
/// If an implementer has not been set for this interfaceID and name, the resolver will query
/// the contract at `addr()`. If `addr()` is set, a contract exists at that address, and that
/// contract implements EIP165 and returns `true` for the specified interfaceID, its address
/// will be returned.
/// @param node The ENS node to query.
/// @param interfaceID The EIP 165 interface ID to check for.
/// @return The address that implements this interface, or 0 if the interface is unsupported.
function interfaceImplementer(
bytes32 node,
bytes4 interfaceID
) external view returns (address);
}
lib/ens-contracts/contracts/resolvers/profiles/INameResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface INameResolver {
event NameChanged(bytes32 indexed node, string name);
/// 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 returns (string memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IPubkeyResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IPubkeyResolver {
event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);
/// Returns the SECP256k1 public key associated with an ENS node.
/// Defined in EIP 619.
/// @param node The ENS node to query
/// @return x The X coordinate of the curve point for the public key.
/// @return y The Y coordinate of the curve point for the public key.
function pubkey(bytes32 node) external view returns (bytes32 x, bytes32 y);
}
lib/ens-contracts/contracts/resolvers/profiles/ITextResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface ITextResolver {
event TextChanged(
bytes32 indexed node,
string indexed indexedKey,
string key,
string 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 returns (string memory);
}
lib/ens-contracts/contracts/resolvers/profiles/IVersionableResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IVersionableResolver {
event VersionChanged(bytes32 indexed node, uint64 newVersion);
function recordVersions(bytes32 node) external view returns (uint64);
}
lib/ens-contracts/contracts/resolvers/profiles/InterfaceResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "../ResolverBase.sol";
import "./AddrResolver.sol";
import "./IInterfaceResolver.sol";
abstract contract InterfaceResolver is IInterfaceResolver, AddrResolver {
mapping(uint64 => mapping(bytes32 => mapping(bytes4 => address))) versionable_interfaces;
/// Sets an interface associated with a name.
/// Setting the address to 0 restores the default behaviour of querying the contract at `addr()` for interface support.
/// @param node The node to update.
/// @param interfaceID The EIP 165 interface ID.
/// @param implementer The address of a contract that implements this interface for this node.
function setInterface(
bytes32 node,
bytes4 interfaceID,
address implementer
) external virtual authorised(node) {
versionable_interfaces[recordVersions[node]][node][
interfaceID
] = implementer;
emit InterfaceChanged(node, interfaceID, implementer);
}
/// Returns the address of a contract that implements the specified interface for this name.
/// If an implementer has not been set for this interfaceID and name, the resolver will query
/// the contract at `addr()`. If `addr()` is set, a contract exists at that address, and that
/// contract implements EIP165 and returns `true` for the specified interfaceID, its address
/// will be returned.
/// @param node The ENS node to query.
/// @param interfaceID The EIP 165 interface ID to check for.
/// @return The address that implements this interface, or 0 if the interface is unsupported.
function interfaceImplementer(
bytes32 node,
bytes4 interfaceID
) external view virtual override returns (address) {
address implementer = versionable_interfaces[recordVersions[node]][
node
][interfaceID];
if (implementer != address(0)) {
return implementer;
}
address a = addr(node);
if (a == address(0)) {
return address(0);
}
(bool success, bytes memory returnData) = a.staticcall(
abi.encodeWithSignature(
"supportsInterface(bytes4)",
type(IERC165).interfaceId
)
);
if (!success || returnData.length < 32 || returnData[31] == 0) {
// EIP 165 not supported by target
return address(0);
}
(success, returnData) = a.staticcall(
abi.encodeWithSignature("supportsInterface(bytes4)", interfaceID)
);
if (!success || returnData.length < 32 || returnData[31] == 0) {
// Specified interface not supported by target
return address(0);
}
return a;
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IInterfaceResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/profiles/NameResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "../ResolverBase.sol";
import "./INameResolver.sol";
abstract contract NameResolver is INameResolver, ResolverBase {
mapping(uint64 => mapping(bytes32 => string)) versionable_names;
/// 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.
function setName(
bytes32 node,
string calldata newName
) external virtual authorised(node) {
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];
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(INameResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/profiles/PubkeyResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "../ResolverBase.sol";
import "./IPubkeyResolver.sol";
abstract contract PubkeyResolver is IPubkeyResolver, ResolverBase {
struct PublicKey {
bytes32 x;
bytes32 y;
}
mapping(uint64 => mapping(bytes32 => PublicKey)) versionable_pubkeys;
/// Sets the SECP256k1 public key associated with an ENS node.
/// @param node The ENS node to query
/// @param x the X coordinate of the curve point for the public key.
/// @param y the Y coordinate of the curve point for the public key.
function setPubkey(
bytes32 node,
bytes32 x,
bytes32 y
) external virtual authorised(node) {
versionable_pubkeys[recordVersions[node]][node] = PublicKey(x, y);
emit PubkeyChanged(node, x, y);
}
/// Returns the SECP256k1 public key associated with an ENS node.
/// Defined in EIP 619.
/// @param node The ENS node to query
/// @return x The X coordinate of the curve point for the public key.
/// @return y The Y coordinate of the curve point for the public key.
function pubkey(
bytes32 node
) external view virtual override returns (bytes32 x, bytes32 y) {
uint64 currentRecordVersion = recordVersions[node];
return (
versionable_pubkeys[currentRecordVersion][node].x,
versionable_pubkeys[currentRecordVersion][node].y
);
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IPubkeyResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/resolvers/profiles/TextResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "../ResolverBase.sol";
import "./ITextResolver.sol";
abstract contract TextResolver is ITextResolver, ResolverBase {
mapping(uint64 => mapping(bytes32 => mapping(string => string))) versionable_texts;
/// Sets the text data associated with an ENS node and key.
/// May only be called by the owner of that node in the ENS registry.
/// @param node The node to update.
/// @param key The key to set.
/// @param value The text data value to set.
function setText(
bytes32 node,
string calldata key,
string calldata value
) external virtual authorised(node) {
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];
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(ITextResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
lib/ens-contracts/contracts/utils/BytesUtils.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {LibMem} from "./LibMem/LibMem.sol";
library BytesUtils {
/// @dev `offset` was beyond `length`.
/// Error selector: `0x8a3c1cfb`
error OffsetOutOfBoundsError(uint256 offset, uint256 length);
/// @dev Assert `end` is not beyond the length of `v`.
function _checkBound(bytes memory v, uint256 end) internal pure {
if (end > v.length) {
revert OffsetOutOfBoundsError(end, v.length);
}
}
/// @dev Compute `keccak256(v[off:off+len])`.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @param len The number of bytes to hash.
/// @return ret The corresponding hash.
function keccak(
bytes memory v,
uint256 off,
uint256 len
) internal pure returns (bytes32 ret) {
_checkBound(v, off + len);
assembly ("memory-safe") {
ret := keccak256(add(add(v, 32), off), len)
}
}
/// @dev Lexicographically compare two byte strings.
/// @param vA The first bytes to compare.
/// @param vB The second bytes to compare.
/// @return Positive number if `A > B`, negative number if `A < B`, or zero if `A == B`.
function compare(
bytes memory vA,
bytes memory vB
) internal pure returns (int256) {
return compare(vA, 0, vA.length, vB, 0, vB.length);
}
/// @dev Lexicographically compare two byte ranges: `A = vA[offA:offA+lenA]` and `B = vB[offB:offB+lenB]`.
/// @param vA The first bytes.
/// @param offA The offset of the first bytes.
/// @param lenA The length of the first bytes.
/// @param vB The second bytes.
/// @param offB The offset of the second bytes.
/// @param lenB The length of the second bytes.
/// @return Positive number if `A > B`, negative number if `A < B`, or zero if `A == B`.
function compare(
bytes memory vA,
uint256 offA,
uint256 lenA,
bytes memory vB,
uint256 offB,
uint256 lenB
) internal pure returns (int256) {
_checkBound(vA, offA + lenA);
_checkBound(vB, offB + lenB);
unchecked {
uint256 ptrA = LibMem.ptr(vA) + offA;
uint256 ptrB = LibMem.ptr(vB) + offB;
uint256 shortest = lenA < lenB ? lenA : lenB;
for (uint256 i; i < shortest; i += 32) {
uint256 a = LibMem.load(ptrA + i);
uint256 b = LibMem.load(ptrB + i);
if (a != b) {
uint256 rest = shortest - i;
if (rest < 32) {
rest = (32 - rest) << 3; // bits to drop
a >>= rest; // shift out the
b >>= rest; // irrelevant bits
}
if (a < b) {
return -1;
} else if (a > b) {
return 1;
}
}
}
}
return int256(lenA) - int256(lenB);
}
/// @dev Determine if `a[offA:offA+len] == b[offB:offB+len]`.
/// @param vA The first bytes.
/// @param offA The offset into the first bytes.
/// @param vB The second bytes.
/// @param offB The offset into the second bytes.
/// @param len The number of bytes to compare.
/// @return True if the byte ranges are equal.
function equals(
bytes memory vA,
uint256 offA,
bytes memory vB,
uint256 offB,
uint256 len
) internal pure returns (bool) {
return keccak(vA, offA, len) == keccak(vB, offB, len);
}
/// @dev Determine if `a[offA:] == b[offB:]`.
/// @param vA The first bytes.
/// @param offA The offset into the first bytes.
/// @param vB The second bytes.
/// @param offB The offset into the second bytes.
/// @return True if the byte ranges are equal.
function equals(
bytes memory vA,
uint256 offA,
bytes memory vB,
uint256 offB
) internal pure returns (bool) {
_checkBound(vA, offA);
_checkBound(vB, offB);
unchecked {
return
keccak(vA, offA, vA.length - offA) ==
keccak(vB, offB, vB.length - offB);
}
}
/// @dev Determine if `a[offA:] == b`.
/// @param vA The first bytes.
/// @param offA The offset into the first bytes.
/// @param vB The second bytes.
/// @return True if the byte ranges are equal.
function equals(
bytes memory vA,
uint256 offA,
bytes memory vB
) internal pure returns (bool) {
return
vA.length == offA + vB.length &&
keccak(vA, offA, vB.length) == keccak256(vB);
}
/// @dev Determine if `a == b`.
/// @param vA The first bytes.
/// @param vB The second bytes.
/// @return True if the bytes are equal.
function equals(
bytes memory vA,
bytes memory vB
) internal pure returns (bool) {
return vA.length == vB.length && keccak256(vA) == keccak256(vB);
}
/// @dev Returns `uint8(v[off])`.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @return The corresponding `uint8`.
function readUint8(
bytes memory v,
uint256 off
) internal pure returns (uint8) {
_checkBound(v, off + 1);
unchecked {
return uint8(v[off]);
}
}
/// @dev Returns `uint16(bytes2(v[off:off+2]))`.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @return ret The corresponding `uint16`.
function readUint16(
bytes memory v,
uint256 off
) internal pure returns (uint16 ret) {
_checkBound(v, off + 2);
assembly ("memory-safe") {
ret := shr(240, mload(add(add(v, 32), off)))
}
}
/// @dev Returns `uint32(bytes4(v[off:off+4]))`.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @return ret The corresponding `uint32`.
function readUint32(
bytes memory v,
uint256 off
) internal pure returns (uint32 ret) {
_checkBound(v, off + 4);
assembly ("memory-safe") {
ret := shr(224, mload(add(add(v, 32), off)))
}
}
/// @dev Returns `bytes20(v[off:off+20])`.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @return ret The corresponding `bytes20`.
function readBytes20(
bytes memory v,
uint256 off
) internal pure returns (bytes20 ret) {
_checkBound(v, off + 20);
assembly ("memory-safe") {
ret := shl(96, mload(add(add(v, 20), off)))
}
}
/// @dev Returns `bytes32(v[off:off+32])`.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @return ret The corresponding `bytes32`.
function readBytes32(
bytes memory v,
uint256 off
) internal pure returns (bytes32 ret) {
_checkBound(v, off + 32);
assembly ("memory-safe") {
ret := mload(add(add(v, 32), off))
}
}
/// @dev Returns `bytes32(bytesN(v[off:off+len]))`.
/// Accepts 0-32 bytes or reverts.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @param len The number of bytes.
/// @return ret The corresponding N-bytes left-aligned in a `bytes32`.
function readBytesN(
bytes memory v,
uint256 off,
uint256 len
) internal pure returns (bytes32 ret) {
assert(len <= 32);
_checkBound(v, off + len);
assembly ("memory-safe") {
let mask := sub(shl(shl(3, sub(32, len)), 1), 1) // <(32-N)x00><NxFF>
ret := and(mload(add(add(v, 32), off)), not(mask))
}
}
/// @dev Copy `vSrc[offSrc:offSrc+len]` to `vDst[offDst:offDst:len]`.
/// @param vSrc The source bytes.
/// @param offSrc The offset into the source to begin the copy.
/// @param vDst The destination bytes.
/// @param offDst The offset into the destination to place the copy.
/// @param len The number of bytes to copy.
function copyBytes(
bytes memory vSrc,
uint256 offSrc,
bytes memory vDst,
uint256 offDst,
uint256 len
) internal pure {
_checkBound(vSrc, offSrc + len);
_checkBound(vDst, offDst + len);
unchecked {
LibMem.copy(
LibMem.ptr(vDst) + offDst,
LibMem.ptr(vSrc) + offSrc,
len
);
}
}
/// @dev Copies a substring into a new byte string.
/// @param vSrc The byte string to copy from.
/// @param off The offset to start copying at.
/// @param len The number of bytes to copy.
/// @return vDst The copied substring.
function substring(
bytes memory vSrc,
uint256 off,
uint256 len
) internal pure returns (bytes memory vDst) {
vDst = new bytes(len);
copyBytes(vSrc, off, vDst, 0, len);
}
/// @dev Find the first occurrence of `needle`.
/// @param v The bytes to search.
/// @param off The offset to start searching.
/// @param len The number of bytes to search.
/// @param needle The byte to search for.
/// @return The offset of `needle`, or `type(uint256).max` if not found.
function find(
bytes memory v,
uint256 off,
uint256 len,
bytes1 needle
) internal pure returns (uint256) {
for (uint256 end = off + len; off < end; off++) {
if (v[off] == needle) {
return off;
}
}
return type(uint256).max;
}
/// @dev Returns `true` if word contains a zero byte.
function hasZeroByte(uint256 word) internal pure returns (bool) {
unchecked {
return
((~word &
(word -
0x0101010101010101010101010101010101010101010101010101010101010101)) &
0x8080808080808080808080808080808080808080808080808080808080808080) !=
0;
}
}
/// @dev Efficiently check if `v[off:off+len]` contains `needle` byte.
/// @param v The source bytes.
/// @param off The offset into the source.
/// @param len The number of bytes to search.
/// @param needle The byte to search for.
/// @return found `true` if `needle` was found.
function includes(
bytes memory v,
uint256 off,
uint256 len,
bytes1 needle
) internal pure returns (bool found) {
_checkBound(v, off + len);
unchecked {
uint256 wide = uint8(needle);
wide |= wide << 8;
wide |= wide << 16;
wide |= wide << 32;
wide |= wide << 64;
wide |= wide << 128; // broadcast byte across word
off += LibMem.ptr(v);
len += off;
while (off < len) {
uint256 word = LibMem.load(off) ^ wide; // zero needle byte
off += 32;
if (hasZeroByte(word)) {
return
off <= len ||
hasZeroByte(
word | ((1 << ((off - len) << 3)) - 1) // recheck overflow by making it nonzero
);
}
}
}
}
}
lib/ens-contracts/contracts/utils/ENSIP19.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {HexUtils} from "../utils/HexUtils.sol";
import {NameCoder} from "../utils/NameCoder.sol";
uint32 constant CHAIN_ID_ETH = 1;
uint256 constant COIN_TYPE_ETH = 60;
uint256 constant COIN_TYPE_DEFAULT = 1 << 31; // 0x8000_0000
string constant SLUG_ETH = "addr"; // <=> COIN_TYPE_ETH
string constant SLUG_DEFAULT = "default"; // <=> COIN_TYPE_DEFAULT
string constant TLD_REVERSE = "reverse";
/// @dev Library for generating reverse names according to ENSIP-19.
/// https://docs.ens.domains/ensip/19
library ENSIP19 {
/// @dev The supplied address was `0x`.
/// Error selector: `0x7138356f`
error EmptyAddress();
/// @dev Extract Chain ID from `coinType`.
/// @param coinType The coin type.
/// @return The Chain ID or 0 if non-EVM Chain.
function chainFromCoinType(
uint256 coinType
) internal pure returns (uint32) {
if (coinType == COIN_TYPE_ETH) return CHAIN_ID_ETH;
coinType ^= COIN_TYPE_DEFAULT;
return uint32(coinType < COIN_TYPE_DEFAULT ? coinType : 0);
}
/// @dev Determine if Coin Type is for an EVM address.
/// @param coinType The coin type.
/// @return True if coin type represents an EVM address.
function isEVMCoinType(uint256 coinType) internal pure returns (bool) {
return coinType == COIN_TYPE_DEFAULT || chainFromCoinType(coinType) > 0;
}
/// @dev Generate Reverse Name from Address + Coin Type.
/// Reverts `EmptyAddress` if `addressBytes` is `0x`.
/// @param addressBytes The input address.
/// @param coinType The coin type.
/// @return The ENS reverse name, eg. `1234abcd.addr.reverse`.
function reverseName(
bytes memory addressBytes,
uint256 coinType
) internal pure returns (string memory) {
if (addressBytes.length == 0) {
revert EmptyAddress();
}
return
string(
abi.encodePacked(
HexUtils.bytesToHex(addressBytes),
bytes1("."),
coinType == COIN_TYPE_ETH
? SLUG_ETH
: coinType == COIN_TYPE_DEFAULT
? SLUG_DEFAULT
: HexUtils.unpaddedUintToHex(coinType, true),
bytes1("."),
TLD_REVERSE
)
);
}
/// @dev Parse Reverse Name into Address + Coin Type.
/// Matches: `/^[0-9a-fA-F]+\.([0-9a-f]{1,64}|addr|default)\.reverse$/`.
/// Reverts `DNSDecodingFailed`.
/// @param name The DNS-encoded name.
/// @return addressBytes The address or empty if invalid.
/// @return coinType The coin type.
function parse(
bytes memory name
) internal pure returns (bytes memory addressBytes, uint256 coinType) {
(, uint256 offset) = NameCoder.readLabel(name, 0);
bool valid;
(addressBytes, valid) = HexUtils.hexToBytes(name, 1, offset);
if (!valid || addressBytes.length == 0) return ("", 0); // addressBytes not 1+ hex
(valid, coinType) = parseNamespace(name, offset);
if (!valid) return ("", 0); // invalid namespace
}
/// @dev Parse Reverse Namespace into Coin Type.
/// Matches: `/^([0-9a-f]{1,64}|addr|default)\.reverse$/`.
/// Reverts `DNSDecodingFailed`.
/// @param name The DNS-encoded name.
/// @param offset The offset to begin parsing.
/// @return valid True if a valid reverse namespace.
/// @return coinType The coin type.
function parseNamespace(
bytes memory name,
uint256 offset
) internal pure returns (bool valid, uint256 coinType) {
(bytes32 labelHash, uint256 offsetTLD) = NameCoder.readLabel(
name,
offset
);
if (labelHash == keccak256(bytes(SLUG_ETH))) {
coinType = COIN_TYPE_ETH;
} else if (labelHash == keccak256(bytes(SLUG_DEFAULT))) {
coinType = COIN_TYPE_DEFAULT;
} else if (labelHash == bytes32(0)) {
return (false, 0); // no slug
} else {
(bytes32 word, bool validHex) = HexUtils.hexStringToBytes32(
name,
1 + offset,
offsetTLD
);
if (!validHex) return (false, 0); // invalid coinType or too long
coinType = uint256(word);
}
(labelHash, offset) = NameCoder.readLabel(name, offsetTLD);
if (labelHash != keccak256(bytes(TLD_REVERSE))) return (false, 0); // invalid tld
(labelHash, ) = NameCoder.readLabel(name, offset);
if (labelHash != bytes32(0)) return (false, 0); // not tld
valid = true;
}
}
lib/ens-contracts/contracts/utils/HexUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
library HexUtils {
/// @dev Convert `hexString[off:end]` to `bytes32`.
/// Accepts 0-64 hex-chars.
/// Uses right alignment: `1` → `0000000000000000000000000000000000000000000000000000000000000001`.
/// @param hexString The string to parse.
/// @param off The index to start parsing.
/// @param end The (exclusive) index to stop parsing.
/// @return word The parsed bytes32.
/// @return valid True if the parse was successful.
function hexStringToBytes32(
bytes memory hexString,
uint256 off,
uint256 end
) internal pure returns (bytes32 word, bool valid) {
if (end < off) return ("", false); // invalid range
uint256 nibbles = end - off;
if (nibbles > 64 || end > hexString.length) {
return (bytes32(0), false); // too large or out of bounds
}
uint256 src;
assembly {
src := add(add(hexString, 32), off)
}
valid = unsafeBytes(src, 0, nibbles);
assembly {
let pad := sub(32, shr(1, add(nibbles, 1))) // number of bytes
word := shr(shl(3, pad), mload(0)) // right align
}
}
/// @dev Convert `hexString[off:end]` to `address`.
/// Accepts exactly 40 hex-chars.
/// @param hexString The string to parse.
/// @param off The index to start parsing.
/// @param end The (exclusive) index to stop parsing.
/// @return addr The parsed address.
/// @return valid True if the parse was successful.
function hexToAddress(
bytes memory hexString,
uint256 off,
uint256 end
) internal pure returns (address addr, bool valid) {
if (off + 40 != end) return (address(0), false); // wrong length
bytes32 word;
(word, valid) = hexStringToBytes32(hexString, off, end);
addr = address(uint160(uint256(word)));
}
/// @dev Convert `hexString[off:end]` to `bytes`.
/// Accepts 0+ hex-chars.
/// @param hexString The string to parse.
/// @param off The index to start parsing.
/// @param end The (exclusive) index to stop parsing.
/// @return v The parsed bytes.
/// @return valid True if the parse was successful.
function hexToBytes(
bytes memory hexString,
uint256 off,
uint256 end
) internal pure returns (bytes memory v, bool valid) {
if (end < off) return ("", false); // invalid range
uint256 nibbles = end - off;
v = new bytes((1 + nibbles) >> 1); // round up
uint256 src;
uint256 dst;
assembly {
src := add(add(hexString, 32), off)
dst := add(v, 32)
}
valid = unsafeBytes(src, dst, nibbles);
}
/// @dev Convert arbitrary hex-encoded memory to bytes.
/// If nibbles is odd, leading hex-char is padded, eg. `F` → `0x0F`.
/// Matches: `/^[0-9a-f]*$/i`.
/// @param src The memory offset of first hex-char of input.
/// @param dst The memory offset of first byte of output (cannot alias `src`).
/// @param nibbles The number of hex-chars to convert.
/// @return valid True if all characters were hex.
function unsafeBytes(
uint256 src,
uint256 dst,
uint256 nibbles
) internal pure returns (bool valid) {
assembly {
function getHex(c, i) -> ascii {
c := byte(i, c)
// chars 48-57: 0-9
if and(gt(c, 47), lt(c, 58)) {
ascii := sub(c, 48)
leave
}
// chars 65-70: A-F
if and(gt(c, 64), lt(c, 71)) {
ascii := add(sub(c, 65), 10)
leave
}
// chars 97-102: a-f
if and(gt(c, 96), lt(c, 103)) {
ascii := add(sub(c, 97), 10)
leave
}
// invalid char
ascii := 0x100
}
valid := true
let end := add(src, nibbles)
if and(nibbles, 1) {
let b := getHex(mload(src), 0) // "f" -> 15
mstore8(dst, b) // write ascii byte
src := add(src, 1) // update pointers
dst := add(dst, 1)
if gt(b, 255) {
valid := false
src := end // terminate loop
}
}
// prettier-ignore
for {} lt(src, end) {
src := add(src, 2) // 2 nibbles
dst := add(dst, 1) // per byte
} {
let word := mload(src) // read word (left aligned)
let b := or(shl(4, getHex(word, 0)), getHex(word, 1)) // "ff" -> 255
if gt(b, 255) {
valid := false
break
}
mstore8(dst, b) // write ascii byte
}
}
}
/// @dev Format `address` as a hex string.
/// @param addr The address to format.
/// @return hexString The corresponding hex string w/o a 0x-prefix.
function addressToHex(
address addr
) internal pure returns (string memory hexString) {
// return bytesToHex(abi.encodePacked(addr));
hexString = new string(40);
uint256 dst;
assembly {
mstore(0, addr)
dst := add(hexString, 32)
}
unsafeHex(12, dst, 40);
}
/// @dev Format `uint256` as a variable-length hex string without zero padding.
/// * unpaddedUintToHex(0, true) = "0"
/// * unpaddedUintToHex(1, true) = "1"
/// * unpaddedUintToHex(0, false) = "00"
/// * unpaddedUintToHex(1, false) = "01"
/// @param value The number to format.
/// @param dropZeroNibble If true, the leading byte will use one nibble if less than 16.
/// @return hexString The corresponding hex string w/o an 0x-prefix.
function unpaddedUintToHex(
uint256 value,
bool dropZeroNibble
) internal pure returns (string memory hexString) {
uint256 temp = value;
uint256 shift;
for (uint256 b = 128; b >= 8; b >>= 1) {
if (temp < (1 << b)) {
shift += b; // number of zero upper bits
} else {
temp >>= b; // shift away lower half
}
}
if (dropZeroNibble && temp < 16) shift += 4;
uint256 nibbles = 64 - (shift >> 2);
hexString = new string(nibbles);
uint256 dst;
assembly {
mstore(0, shl(shift, value)) // left-align
dst := add(hexString, 32)
}
unsafeHex(0, dst, nibbles);
}
/// @dev Format `bytes` as a hex string.
/// @param v The bytes to format.
/// @return hexString The corresponding hex string w/o a 0x-prefix.
function bytesToHex(
bytes memory v
) internal pure returns (string memory hexString) {
uint256 nibbles = v.length << 1;
hexString = new string(nibbles);
uint256 src;
uint256 dst;
assembly {
src := add(v, 32)
dst := add(hexString, 32)
}
unsafeHex(src, dst, nibbles);
}
/// @dev Converts arbitrary memory to a hex string.
/// @param src The memory offset of first nibble of input.
/// @param dst The memory offset of first hex-char of output (can alias `src`).
/// @param nibbles The number of nibbles to convert and the byte-length of the output.
function unsafeHex(
uint256 src,
uint256 dst,
uint256 nibbles
) internal pure {
unchecked {
for (uint256 end = dst + nibbles; dst < end; src += 32) {
uint256 word;
assembly {
word := mload(src)
}
for (uint256 shift = 256; dst < end && shift > 0; dst++) {
uint256 b = (word >> (shift -= 4)) & 15; // each nibble
b = b < 10 ? b + 0x30 : b + 0x57; // ("a" - 10) => 0x57
assembly {
mstore8(dst, b)
}
}
}
}
}
}
lib/ens-contracts/contracts/utils/LibMem/LibMem.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
library LibMem {
/// @dev Copy `mem[src:src+len]` to `mem[dst:dst+len]`.
/// Equivalent to `mcopy()`.
///
/// @param src The source memory offset.
/// @param dst The destination memory offset.
/// @param len The number of bytes to copy.
function copy(uint256 dst, uint256 src, uint256 len) internal pure {
assembly {
// Copy word-length chunks while possible
// prettier-ignore
for {} gt(len, 31) {} {
mstore(dst, mload(src))
dst := add(dst, 32)
src := add(src, 32)
len := sub(len, 32)
}
// Copy remaining bytes
if len {
let mask := sub(shl(shl(3, sub(32, len)), 1), 1)
let wSrc := and(mload(src), not(mask))
let wDst := and(mload(dst), mask)
mstore(dst, or(wSrc, wDst))
}
}
}
/// @dev Convert bytes to a memory offset.
///
/// @param v The bytes to convert.
///
/// @return ret The corresponding memory offset.
function ptr(bytes memory v) internal pure returns (uint256 ret) {
assembly {
ret := add(v, 32)
}
}
/// @dev Read word at memory offset.
///
/// @param src The memory offset.
///
/// @return ret The read word.
function load(uint256 src) internal pure returns (uint256 ret) {
assembly {
ret := mload(src)
}
}
}
lib/ens-contracts/contracts/utils/NameCoder.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {LibMem} from "./LibMem/LibMem.sol";
import {BytesUtils} from "./BytesUtils.sol";
/// @dev Library for encoding/decoding names.
///
/// An ENS name is stop-separated labels, eg. "aaa.bb.c".
///
/// A DNS-encoded name is composed of byte length-prefixed labels with a terminator byte.
/// eg. "\x03aaa\x02bb\x01c\x00".
///
/// * maximum label length is 255 bytes.
/// * length = 0 is reserved for the terminator (root).
/// * `dns.length == 2 + ens.length` and the mapping is injective.
///
library NameCoder {
/// @dev The namehash of "eth".
bytes32 public constant ETH_NODE =
0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae;
/// @dev The label was empty.
/// Error selector: `0xbf9a2740`
error LabelIsEmpty();
/// @dev The label was more than 255 bytes.
/// Error selector: `0xdab6c73c`
error LabelIsTooLong(string label);
/// @dev The DNS-encoded name is malformed.
/// Error selector: `0xba4adc23`
error DNSDecodingFailed(bytes dns);
/// @dev A label of the ENS name has an invalid size.
/// Error selector: `0x9a4c3e3b`
error DNSEncodingFailed(string ens);
/// @dev The `name` did not end with `suffix`.
///
/// @param name The DNS-encoded name.
/// @param suffix The DNS-encoded suffix.
error NoSuffixMatch(bytes name, bytes suffix);
/// @dev Read the `size` of the label at `offset`.
/// If `size = 0`, it must be the end of `name` (no junk at end).
/// Reverts `DNSDecodingFailed`.
///
/// @param name The DNS-encoded name.
/// @param offset The offset into `name` to start reading.
///
/// @return size The size of the label in bytes.
/// @return nextOffset The offset into `name` of the next label.
function nextLabel(
bytes memory name,
uint256 offset
) internal pure returns (uint8 size, uint256 nextOffset) {
unchecked {
if (offset >= name.length) {
revert DNSDecodingFailed(name);
}
size = uint8(name[offset]);
nextOffset = offset + 1 + size;
if (
size > 0 ? nextOffset >= name.length : nextOffset != name.length
) {
revert DNSDecodingFailed(name);
}
}
}
/// @dev Find the offset of the label before `offset` in `name`.
/// * `prevOffset(name, 0)` reverts
/// * `prevOffset(name, name.length + 1)` reverts
/// * `prevOffset(name, name.length) = name.length - 1`
/// * `prevOffset(name, name.length - 1) = <tld>`
/// Reverts `DNSDecodingFailed`.
///
/// @param name The DNS-encoded name.
/// @param offset The offset into `name` to start reading backwards.
///
/// @return prevOffset The offset into `name` of the previous label.
function prevLabel(
bytes memory name,
uint256 offset
) internal pure returns (uint256 prevOffset) {
while (true) {
(, uint256 nextOffset) = nextLabel(name, prevOffset);
if (nextOffset == offset) break;
if (nextOffset > offset) {
revert DNSDecodingFailed(name);
}
prevOffset = nextOffset;
}
}
/// @dev Count number of labels in `name`.
/// * `countLabels("\x03eth\x00") = 1`
/// * `countLabels("\x00") = 0`
/// Reverts like `nextLabel()`.
///
/// @param name The DNS-encoded parent name.
/// @param offset The offset into `name` to start hashing.
///
/// @return count The number of labels.
function countLabels(
bytes memory name,
uint256 offset
) internal pure returns (uint256 count) {
uint8 size;
while (true) {
(size, offset) = nextLabel(name, offset);
if (size == 0) break;
++count;
}
}
/// @dev Compute the ENS labelhash of the label at `offset` and the offset for the next label.
/// Reverts `DNSDecodingFailed`.
///
/// @param name The DNS-encoded name.
/// @param offset The offset into `name` to start reading.
///
/// @return labelHash The resulting labelhash.
/// @return nextOffset The offset into `name` of the next label.
function readLabel(
bytes memory name,
uint256 offset
) internal pure returns (bytes32 labelHash, uint256 nextOffset) {
uint8 size;
(size, nextOffset) = nextLabel(name, offset);
if (size > 0) {
assembly {
labelHash := keccak256(add(add(name, offset), 33), size)
}
}
}
/// @dev Read label at offset from a DNS-encoded name and the offset for the next label.
/// * `readLabel("\x03abc\x00", 0) = ("abc", 4)`
/// * `readLabel("\x00", 0) = ("", 1)`
/// Reverts `DNSDecodingFailed`.
///
/// @param name The DNS-encoded name.
/// @param offset The offset into `name` to start reading.
///
/// @return label The label corresponding to `offset`.
/// @return nextOffset The offset into `name` of the next label.
function extractLabel(
bytes memory name,
uint256 offset
) internal pure returns (string memory label, uint256 nextOffset) {
uint8 size;
(size, nextOffset) = nextLabel(name, offset);
bytes memory v = new bytes(size);
unchecked {
LibMem.copy(LibMem.ptr(v), LibMem.ptr(name) + offset + 1, size);
}
label = string(v);
}
/// @dev Reads first label from a DNS-encoded name.
/// Reverts `DNSDecodingFailed`.
/// Reverts `LabelIsEmpty` if the label was empty.
///
/// @param name The DNS-encoded name.
///
/// @return The first label.
function firstLabel(
bytes memory name
) internal pure returns (string memory) {
(string memory label, ) = extractLabel(name, 0);
if (bytes(label).length == 0) {
revert LabelIsEmpty();
}
return label;
}
/// @dev Compute the namehash of `name[:offset]`.
/// Reverts `DNSDecodingFailed`.
///
/// @param name The DNS-encoded name.
/// @param offset The offset into `name` to start hashing.
///
/// @return hash The namehash of `name[:offset]`.
function namehash(
bytes memory name,
uint256 offset
) internal pure returns (bytes32 hash) {
(hash, offset) = readLabel(name, offset);
if (hash != bytes32(0)) {
hash = namehash(namehash(name, offset), hash);
}
}
/// @dev Compute a child namehash from a parent namehash and child labelhash.
///
/// @param parentNode The namehash of the parent.
/// @param labelHash The labelhash of the child.
///
/// @return node The namehash of the child.
function namehash(
bytes32 parentNode,
bytes32 labelHash
) internal pure returns (bytes32 node) {
// ~100 gas less than: keccak256(abi.encode(parentNode, labelHash))
assembly {
mstore(0, parentNode)
mstore(32, labelHash)
node := keccak256(0, 64)
}
}
/// @dev Convert DNS-encoded name to ENS name.
/// * `decode("\x00") = ""`
/// * `decode("\x03eth\x00") = "eth"`
/// * `decode("\x03aaa\x02bb\x01c\x00") = "aa.bb.c"`
/// * `decode("\x03a.b\x00")` reverts
/// Reverts like `nextLabel()`.
///
/// @param dns The DNS-encoded name to convert.
///
/// @return ens The equivalent ENS name.
function decode(
bytes memory dns
) internal pure returns (string memory ens) {
unchecked {
uint256 n = dns.length;
if (n == 1 && dns[0] == 0) return ""; // only valid answer is root
if (n < 3) revert DNSDecodingFailed(dns);
bytes memory v = new bytes(n - 2); // always 2-shorter
LibMem.copy(LibMem.ptr(v), LibMem.ptr(dns) + 1, n - 2); // shift by -1 byte
uint256 offset;
while (true) {
(uint8 size, uint256 nextOffset) = nextLabel(dns, offset);
if (size == 0) break;
if (BytesUtils.includes(v, offset, size, ".")) {
revert DNSDecodingFailed(dns); // malicious label
}
if (offset > 0) {
v[offset - 1] = ".";
}
offset = nextOffset;
}
return string(v);
}
}
/// @dev Convert ENS name to DNS-encoded name.
/// * `encode("aaa.bb.c") = "\x03aaa\x02bb\x01c\x00"`
/// * `encode("eth") = "\x03eth\x00"`
/// * `encode("") = "\x00"`
/// Reverts `DNSEncodingFailed`.
///
/// @param ens The ENS name to convert.
///
/// @return dns The corresponding DNS-encoded name, eg. `\x03aaa\x02bb\x01c\x00`.
function encode(
string memory ens
) internal pure returns (bytes memory dns) {
unchecked {
uint256 n = bytes(ens).length;
if (n == 0) return hex"00"; // root
dns = new bytes(n + 2); // always 2-longer
LibMem.copy(LibMem.ptr(dns) + 1, LibMem.ptr(bytes(ens)), n); // shift by +1 byte
uint256 start; // remember position to write length
uint256 size;
for (uint256 i; i < n; ++i) {
if (bytes(ens)[i] == ".") {
size = i - start;
if (size == 0 || size > 255) {
revert DNSEncodingFailed(ens);
}
dns[start] = bytes1(uint8(size));
start = i + 1;
}
}
size = n - start;
if (size == 0 || size > 255) {
revert DNSEncodingFailed(ens);
}
dns[start] = bytes1(uint8(size));
}
}
/// @dev Find the offset into `name` that namehashes to `nodeSuffix`.
///
/// @param name The DNS-encoded name to search.
/// @param nodeSuffix The namehash to match.
///
/// @return matched True if `name` ends with `nodeSuffix`.
/// @return node The namehash of `name[offset:]`.
/// @return prevOffset The offset into `name` of the label before `nodeSuffix`, or `matchOffset` if no match or no prior label.
/// @return matchOffset The offset into `name` that namehashes to the `nodeSuffix`, or 0 if no match.
function matchSuffix(
bytes memory name,
uint256 offset,
bytes32 nodeSuffix
)
internal
pure
returns (
bool matched,
bytes32 node,
uint256 prevOffset,
uint256 matchOffset
)
{
(bytes32 labelHash, uint256 next) = readLabel(name, offset);
if (labelHash != bytes32(0)) {
(matched, node, prevOffset, matchOffset) = matchSuffix(
name,
next,
nodeSuffix
);
if (node == nodeSuffix) {
matched = true;
prevOffset = offset;
matchOffset = next;
}
node = namehash(node, labelHash);
}
if (node == nodeSuffix) {
matched = true;
prevOffset = matchOffset = offset;
}
}
/// @dev Assert `label` is an encodable size.
///
/// @param label The label to check.
///
/// @return The size of the label.
function assertLabelSize(
string memory label
) internal pure returns (uint8) {
uint256 n = bytes(label).length;
if (n == 0) revert LabelIsEmpty();
if (n > 255) revert LabelIsTooLong(label);
return uint8(n);
}
/// @dev Prepend `label` to DNS-encoded `name`.
/// * `addLabel("\x03eth\x00", "test") = "\x04test\x03eth\x00"`
/// * `addLabel("\x00", "eth") = "\x03eth\x00"`
/// * `addLabel("", "abc") = "\x03abc"` invalid
/// * `addLabel("", "")` reverts
/// Assumes `name` is properly encoded.
/// Reverts like `assertLabelSize()`.
///
/// @param name The DNS-encoded parent name.
/// @param label The child label to prepend.
///
/// @return The DNS-encoded child name.
function addLabel(
bytes memory name,
string memory label
) internal pure returns (bytes memory) {
return abi.encodePacked(assertLabelSize(label), label, name);
}
/// @dev Transform `label` to DNS-encoded `{label}.eth`.
/// * `ethName("eth") = "\x04test\x03eth\x00"`
/// Behaves like `addLabel()`.
///
/// @param label The label to encode.
///
/// @return The DNS-encoded name.
function ethName(string memory label) internal pure returns (bytes memory) {
return addLabel("\x03eth\x00", label);
}
}
lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "paris",
"remappings": [
"forge-std/=lib/forge-std/src/",
"ens-contracts/=lib/ens-contracts/contracts/",
"ens-contracts-v2/=lib/contracts-v2/contracts/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@ensdomains/buffer/=lib/buffer/",
"@chainlink/contracts/=lib/chainlink-brownie-contracts/contracts/",
"buffer/=lib/buffer/contracts/",
"chainlink-brownie-contracts/=lib/chainlink-brownie-contracts/",
"contracts-v2/=lib/contracts-v2/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/contracts-v2/contracts/lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/contracts-v2/contracts/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts-v4/=lib/contracts-v2/contracts/lib/openzeppelin-contracts-v4/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"optimism/=lib/contracts-v2/contracts/lib/unruggable-gateways/lib/optimism/packages/contracts-bedrock/src/",
"solsha1/=lib/contracts-v2/contracts/lib/solsha1/contracts/",
"unruggable-gateways/=lib/contracts-v2/contracts/lib/unruggable-gateways/contracts/",
"verifiable-factory/=lib/contracts-v2/contracts/lib/verifiable-factory/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.