Skip to content

Commit

Permalink
Update ownerhash[addr] to accept keccak(addr) (#31)
Browse files Browse the repository at this point in the history
* README update

* Purge masterhash()

* README.md update

* README.md update: 2

* Reinstate signedRedirect() & ownerhash[]

* some more NatSpec

* Goerli-v4: 0x4b9A4521442485ad7e1b25295125240b5f3F5aaC

* Remove redundant parts; more natSpec

* update ownerhash[addr] to accept keccak(addr)
  • Loading branch information
sshmatrix committed Jul 19, 2023
1 parent eff1daf commit bc2a2f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/CCIP2ETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract CCIP2ETH is iCCIP2ETH {
*/
mapping(bytes32 => bytes) public recordhash;
/// @dev - Owner-specific contenthash storing records for all names owned by a wallet
mapping(address => bytes) public ownerhash;
mapping(bytes32 => bytes) public ownerhash;
/// @dev - On-chain singular Manager database
/// Note - Manager (= isApprovedSigner) is someone who can manage off-chain records for a domain on behalf of its owner
mapping(address => mapping(bytes32 => mapping(address => bool))) public isApprovedSigner;
Expand All @@ -65,7 +65,6 @@ contract CCIP2ETH is iCCIP2ETH {
supportsInterface[iERC165.supportsInterface.selector] = true;
supportsInterface[iENSIP10.resolve.selector] = true;
supportsInterface[type(iERC173).interfaceId] = true;
supportsInterface[iCCIP2ETH.recordhash.selector] = true;
supportsInterface[iCCIP2ETH.setRecordhash.selector] = true;
}

Expand Down Expand Up @@ -103,7 +102,7 @@ contract CCIP2ETH is iCCIP2ETH {
bytes32 _namehash = _node;
if (_node == bytes32(0)) {
// Set ownerhash if no node is provided
ownerhash[msg.sender] = _contenthash;
ownerhash[keccak256(abi.encodePacked(msg.sender))] = _contenthash;
} else {
// Set recordhash otherwise
address _owner = ENS.owner(_node);
Expand Down Expand Up @@ -161,11 +160,12 @@ contract CCIP2ETH is iCCIP2ETH {
address _owner = ENS.owner(_node);
if (_recordhash.length == 0) {
// Check if recordhash exists
if (ownerhash[_owner].length == 0) {
bytes32 _addrhash = keccak256(abi.encodePacked(_owner));
if (ownerhash[_addrhash].length == 0) {
// Check if ownerhash exists, if no recordhash is found
revert("RECORD_NOT_SET");
}
_recordhash = ownerhash[_owner]; // Fallback to ownerhash in absence of recordhash
_recordhash = ownerhash[_addrhash]; // Fallback to ownerhash in absence of recordhash
}
string memory _recType = gateway.funcToJson(request); // Filename for the requested record
// Update ownership if domain is wrapped
Expand Down
1 change: 0 additions & 1 deletion src/Interface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ interface iCCIP2ETH is iENSIP10 {
view
returns (address _signer);
function setRecordhash(string[] memory _subdomains, bytes32 _node, bytes calldata _contenthash) external;
function recordhash(bytes32 _node) external view returns (bytes memory _contenthash);
}

interface iGatewayManager is iERC173 {
Expand Down

0 comments on commit bc2a2f5

Please sign in to comment.