Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# 🤖 Linear

Closes EFI-XXX
5 changes: 5 additions & 0 deletions src/contracts/L2Resolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ contract L2Resolver is IL2Resolver {
emit RecordSet(_node, _key, _value);
}

/// @inheritdoc IL2Resolver
function getRecord(bytes32 _node, string calldata _key) public view returns (bytes memory _data) {
_data = records[_node][_key];
}

/**
* @notice Returns the owner of a node.
* @dev If the node is the NameWrapper, then the domain is wrapped and it gets the owner from the NameWrapper.
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/IL2Resolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ interface IL2Resolver {
*/
function setRecord(bytes32 _node, string calldata _key, bytes calldata _value) external;

/**
* @notice Retrieves raw bytes for a given node and key from the records mapping.
* @param _node The ENS node to retrieve the data for.
* @param _key The key to retrieve the data under.
* @return _data The data stored under the key. Returns empty bytes if the record is not found.
*/
function getRecord(bytes32 _node, string calldata _key) external view returns (bytes memory _data);

/*///////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////*/
Expand Down
17 changes: 17 additions & 0 deletions test/unit/L2Resolver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ contract UnitL2Resolver is Test {
address internal _ensRegistry = makeAddr('ENSRegistry');
address internal _nameWrapper = makeAddr('NameWrapper');
address internal _reverseAdmin = makeAddr('ReverseAdmin');
address internal _nodeOwner = makeAddr('NodeOwner');
bytes32 internal _parentNodeNameHash = keccak256('l2.eth');
bytes32 internal _reverseLookupNode;
bytes32 internal _nodeNameHash = keccak256('optimism.l2.eth');
Expand Down Expand Up @@ -312,6 +313,22 @@ contract UnitL2Resolver is Test {
_l2Resolver.setRecord(_nodeNameHash, _key, _chainIdBytes);
}

function test_GetRecordWhenTheRecordExists(bytes32 _node, string calldata _recordKey, bytes memory _value) external {
vm.assume(_node != _reverseLookupNode);

_mockAndExpect(address(_ensRegistry), abi.encodeWithSelector(IENS.owner.selector, _node), abi.encode(_nodeOwner));
vm.prank(_nodeOwner);
_l2Resolver.setRecord(_node, _recordKey, _value);

// it returns the stored bytes
assertEq(_l2Resolver.getRecord(_node, _recordKey), _value);
}

function test_GetRecordWhenTheRecordDoesNotExist(bytes32 _node, string calldata _recordKey) external view {
// it returns empty bytes
assertEq(_l2Resolver.getRecord(_node, _recordKey), '');
}

/**
* @notice Sets up a mock and expects a call to it
*
Expand Down
6 changes: 6 additions & 0 deletions test/unit/L2Resolver.tree
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ UnitL2Resolver::setRecord
│ └── it reverts
└── when the caller is not authorized on the parent
└── it reverts

UnitL2Resolver::getRecord
├── when the record exists
│ └── it returns the stored bytes
└── when the record does not exist
└── it returns empty bytes
Loading