Skip to content

Commit

Permalink
Fix for getRecordhash() (#46)
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)

* natSpec for GatewayManager

* Mainnet: 0x57532d78FfBcC6ac5534A9b39899C7eC89082CdA

* Fixes for bugs in v1-beta

* Fixes for bugs in v1-beta (#34)

* Some natSpec and fix for avatar/contenthash

* Updated Fixes in v1.0.0-beta (#36)

* Fixes for bugs in v1-beta

* Some natSpec and fix for avatar/contenthash

* Fix error in test.yml

* Fix errors in test.yml  (#38)

* Fixes for bugs in v1-beta

* Some natSpec and fix for avatar/contenthash

* Fix error in test.yml

* Review of #40

* Fix typo-2

* Re-try merge (#43)

* 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)

* natSpec for GatewayManager

* Mainnet: 0x57532d78FfBcC6ac5534A9b39899C7eC89082CdA

* Fixes for bugs in v1-beta

* Fixes for bugs in v1-beta (#34)

* Some natSpec and fix for avatar/contenthash

* Updated Fixes in v1.0.0-beta (#36)

* Fixes for bugs in v1-beta

* Some natSpec and fix for avatar/contenthash

* Fix error in test.yml

* Fix errors in test.yml  (#38)

* Fixes for bugs in v1-beta

* Some natSpec and fix for avatar/contenthash

* Fix error in test.yml

* Review of #40

* Fix typo-2

* Typo-2

* Typo-2.1

* Typo-2.2

* Get ChainID from ENV

* rSync

* getRecordhash() fix

* Tests for wrapped names
  • Loading branch information
sshmatrix committed Aug 15, 2023
1 parent 484d622 commit 4aca88d
Show file tree
Hide file tree
Showing 3 changed files with 548 additions and 59 deletions.
50 changes: 25 additions & 25 deletions src/CCIP2ETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ contract CCIP2ETH is iCCIP2ETH {

/// @dev - Sets ENS TESTNET wrapper contract
/// @TODO - [!!!] REMOVE FOR MAINNET
isWrapper[0x0000000000000000000000000000000000000000] = true;
emit UpdatedWrapper(0x0000000000000000000000000000000000000000, true);
isWrapper[0x114D4603199df73e7D157787f8778E21fCd13066] = true;
emit UpdatedWrapper(0x114D4603199df73e7D157787f8778E21fCd13066, true);

/// @dev - Set necessary interfaces
supportsInterface[iERC165.supportsInterface.selector] = true;
supportsInterface[iENSIP10.resolve.selector] = true;
supportsInterface[type(iERC173).interfaceId] = true;
supportsInterface[iCCIP2ETH.setRecordhash.selector] = true;
supportsInterface[iCCIP2ETH.setOwnerhash.selector] = true;
supportsInterface[iCallbackType.signedRecord.selector] = true;
supportsInterface[iCallbackType.signedRedirect.selector] = true;
}
Expand All @@ -92,11 +93,13 @@ contract CCIP2ETH is iCCIP2ETH {
/**
* @dev Gets recordhash for a node
* @param _node - Namehash of domain.eth, or bytes32(address _Owner)
* @param _recordhash - IPNS Contenthash to set as recordhash
* @return _recordhash - IPNS contenthash that is set as recordhash
*/
function getRecordhash(bytes32 _node) external view returns (bytes memory _recordhash) {
_recordhash = recordhash[_node];
if (_recordhash.length == 0) {
// Check if first 12 bytes are bytes12(0)
bool _isQueryOwnerhash = _node & bytes32(uint256(0xFFFFFFFFFFFFFFFFFFFFFFFF) >> 96) == bytes32(0);
if (_recordhash.length == 0 && !_isQueryOwnerhash) {
address _owner = ENS.owner(_node);
if (isWrapper[_owner]) {
_owner = iToken(_owner).ownerOf(uint256(_node));
Expand All @@ -112,7 +115,7 @@ contract CCIP2ETH is iCCIP2ETH {
* @dev Sets standard recordhash for a node
* Note - Only ENS owner or manager of node can call
* @param _node - Namehash of domain.eth
* @param _recordhash - IPNS Contenthash to set as recordhash
* @param _recordhash - IPNS contenthash to set as recordhash
*/
function setRecordhash(bytes32 _node, bytes calldata _recordhash) external payable {
address _owner = ENS.owner(_node);
Expand All @@ -131,7 +134,7 @@ contract CCIP2ETH is iCCIP2ETH {
* Note - Without the constant prefix hex'e5010172002408011220'
* Note - Only ENS owner or manager of node can call
* @param _node - Namehash of domain.eth
* @param _recordhash - Short IPNS Contenthash to set as recordhash
* @param _recordhash - Short IPNS contenthash to set as recordhash
*/
function setShortRecordhash(bytes32 _node, bytes32 _recordhash) external payable {
address _owner = ENS.owner(_node);
Expand All @@ -148,7 +151,7 @@ contract CCIP2ETH is iCCIP2ETH {
/**
* @dev Sets ownerhash for an owner
* Note - Wallet-specific fallback recordhash
* @param _recordhash - Short IPNS Contenthash to set as ownerhash
* @param _recordhash - Short IPNS contenthash to set as ownerhash
*/
function setOwnerhash(bytes calldata _recordhash) external payable {
if (msg.value < ownerhashFees) {
Expand All @@ -162,7 +165,7 @@ contract CCIP2ETH is iCCIP2ETH {
* @dev Sets ownerhash for an owner
* Note - Without the constant prefix hex'e5010172002408011220'
* Note - Wallet-specific fallback recordhash
* @param _recordhash - Short IPNS Contenthash to set as ownerhash
* @param _recordhash - Short IPNS contenthash to set as ownerhash
*/
function setShortOwnerhash(bytes32 _recordhash) external payable {
if (msg.value < ownerhashFees) {
Expand All @@ -178,8 +181,8 @@ contract CCIP2ETH is iCCIP2ETH {
* @dev Sets recordhash for a subnode
* Note - Only ENS owner or manager of parent node can call
* @param _node - Namehash of domain.eth
* @param _subdomain - Subdomain labels; a.domain.eth = "a"
* @param _recordhash - Contenthash to set as recordhash
* @param _subdomain - Subdomain labels; sub.domain.eth = "sub"
* @param _recordhash - IPNS contenthash to set as recordhash
*/
function setSubRecordhash(bytes32 _node, string calldata _subdomain, bytes calldata _recordhash) external payable {
address _owner = ENS.owner(_node);
Expand All @@ -199,7 +202,7 @@ contract CCIP2ETH is iCCIP2ETH {
* Note - Only ENS owner or manager of parent node can call
* @param _node - Namehash of domain.eth
* @param _subdomain - Subdomain labels; a.b.c.domain.eth = [a, b, c]
* @param _recordhash - Contenthash to set as recordhash
* @param _recordhash - IPNS contenthash to set as recordhash
*/
function setDeepSubRecordhash(bytes32 _node, string[] calldata _subdomain, bytes calldata _recordhash)
external
Expand Down Expand Up @@ -566,11 +569,22 @@ contract CCIP2ETH is iCCIP2ETH {
}

/// @dev : Management functions

/// @dev - Returns owner of the contract
function owner() public view returns (address) {
return gateway.owner();
}
/// @dev - Updates ChainID in case of a hardfork

function updateChainID() public {
chainID = gateway.uintToString(block.chainid);
}
/**
* @dev Sets fees for ownerhash
* Note - Set to 0 at launch
* @param _wei - Fees in WEI per EOA
*/

function updateOwnerhashFees(uint256 _wei) external OnlyDev {
ownerhashFees = _wei;
}
Expand Down Expand Up @@ -616,20 +630,6 @@ contract CCIP2ETH is iCCIP2ETH {
emit UpdatedWrapper(_addr, _set);
}

/**
* @dev - Updates Chain ID in case of a hardfork
*/
function updateChainID() public {
chainID = gateway.uintToString(block.chainid);
}

/**
* @dev - Owner of contract
*/
function owner() public view returns (address) {
return gateway.owner();
}

/**
* @dev Withdraw Ether to owner; to be used for tips or in case some Ether gets locked in the contract
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Interface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ interface iCCIP2ETH is iENSIP10 {
returns (address _signer);
function setRecordhash(bytes32 _node, bytes calldata _recordhash) external payable;
function setShortRecordhash(bytes32 _node, bytes32 _recordhash) external payable;
function setSubRecordhash(bytes32 _node, string memory _subdomain, bytes calldata _recordhash) external payable;
function setDeepSubRecordhash(bytes32 _node, string[] memory _subdomains, bytes calldata _recordhash)
external
payable;
function setOwnerhash(bytes calldata _recordhash) external payable;
function redirectService(bytes calldata _encoded, bytes calldata _requested)
external
view
returns (bytes4 _selector, bytes32 _namehash, bytes memory _redirectRequest, string memory _domain);
function setDeepSubRecordhash(bytes32 _node, string[] memory _subdomains, bytes calldata _recordhash)
external
payable;
function setSubRecordhash(bytes32 _node, string memory _subdomain, bytes calldata _recordhash) external payable;
}

interface iGatewayManager is iERC173 {
Expand Down
Loading

0 comments on commit 4aca88d

Please sign in to comment.