Skip to content

Commit

Permalink
Merge natSpec (#44)
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
  • Loading branch information
sshmatrix authored Aug 14, 2023
1 parent 46d278c commit 1e31088
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 50 deletions.
38 changes: 0 additions & 38 deletions src/CCIP2ETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -282,44 +282,6 @@ contract CCIP2ETH is iCCIP2ETH {
iCCIP2ETH.__callback.selector, // Callback function
abi.encode(_node, block.number - 1, _checkhash, _domain, _recType, _path, name, request)
);
if (_signer != iCCIP2ETH(this).getSigner(signRequest, _recordSignature)) {
revert InvalidRequest("BAD_SIGNED_RECORD");
}
} else if (_type == iCallbackType.signedDAppService.selector) {
if (result[0] == 0x0 || result[result.length - 1] != 0x0) {
revert InvalidRequest("BAD_DAPP_SERVICE_REQUEST");
}
(bytes4 _req, bytes32 _redirectNamehash, bytes memory _redirectRequest, string memory _redirectDomain) =
iCCIP2ETH(this).redirectService(result, _request);
signRequest = string.concat(
"Requesting Signature To Install DApp Service\n",
"\nOrigin: ",
_domain, // e.g. ens.domain.eth
"\nDApp: ",
_redirectDomain, // e.g. app.ens.eth
"\nExtradata: 0x",
gateway.bytesToHexString(abi.encodePacked(keccak256(result)), 0),
"\nSigned By: eip155:1:",
gateway.toChecksumAddress(_signer)
);
if (_signer != iCCIP2ETH(this).getSigner(signRequest, _recordSignature)) {
revert InvalidRequest("BAD_DAPP_SIGNATURE");
}
address _resolver = ENS.resolver(_redirectNamehash);
if (iERC165(_resolver).supportsInterface(iENSIP10.resolve.selector)) {
return iENSIP10(_resolver).resolve(result, _redirectRequest);
} else if (iERC165(_resolver).supportsInterface(_req)) {
bool ok;
(ok, result) = _resolver.staticcall(_redirectRequest);
if (!ok) {
revert InvalidRequest("BAD_RESOLVER");
}
} else {
revert InvalidRequest("BAD_RESOLVER_FUNCTION");
}
} else {
/// @dev Future features in __fallback
return gateway.__fallback(response, extradata);
}
}

Expand Down
18 changes: 6 additions & 12 deletions test/CCIP2ETH.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ contract CCIP2ETHTest is Test {
)
);
ccip2eth.resolve(_encoded, _request);
_subdomains;
}

/// @dev Test subdomain-level CCIP-Read call
Expand All @@ -116,7 +115,7 @@ contract CCIP2ETHTest is Test {
ENS.setOwner(_namehash, address(this));
bytes memory _recordhash =
hex"e50101720024080112203c5aba6c9b5055a5fa12281c486188ed8ae2b6ef394b3d981b00d17a4b51735c";
ccip2eth.setDeepSubRecordhash(_namehash, _subdomains, _recordhash);
ccip2eth.setRecordhash(_namehash, _recordhash);
(string memory _path, string memory _domain) = utils.Format(_encoded);
bytes memory _request = abi.encodeWithSelector(iResolver.text.selector, _namehash, abi.encode(string("avatar")));
string memory _recType = gateway.funcToJson(_request);
Expand All @@ -136,7 +135,6 @@ contract CCIP2ETHTest is Test {
)
);
ccip2eth.resolve(_encoded, _request);
_subdomains;
}

/// @dev Test deep CCIP-Read call
Expand Down Expand Up @@ -182,7 +180,6 @@ contract CCIP2ETHTest is Test {
)
);
ccip2eth.resolve(_encoded, _request);
_subdomains;
}

/// @dev CCIP end-to-end test with on-chain signer
Expand Down Expand Up @@ -248,7 +245,6 @@ contract CCIP2ETHTest is Test {
bytes memory _response =
abi.encodeWithSelector(iCallbackType.signedRecord.selector, _signer, _signature, bytes("0"), _result);
assertEq(_result, ccip2eth.__callback(_response, _extradata));
_subdomains;
}

/// @dev CCIP end-to-end test with off-chain signer (with fake parameters)
Expand Down Expand Up @@ -335,7 +331,6 @@ contract CCIP2ETHTest is Test {
bytes memory _response =
abi.encodeWithSelector(iCallbackType.signedRecord.selector, _signer, _recordSig, _approvedSig, _result);
assertEq(_result, ccip2eth.__callback(_response, _extradata));
_subdomains;
}

/// @dev CCIP end-to-end with off-chain signer and real parameters
Expand Down Expand Up @@ -422,7 +417,6 @@ contract CCIP2ETHTest is Test {
bytes memory _response =
abi.encodeWithSelector(iCallbackType.signedRecord.selector, _signer, _recordSig, _approvedSig, _result);
assertEq(_result, ccip2eth.__callback(_response, _extradata));
_subdomains;
}

/// @dev Test setting regular and short recordhash
Expand Down Expand Up @@ -460,9 +454,9 @@ contract CCIP2ETHTest is Test {

/// @dev Test setting deep recordhash
function test10_setDeepSubRecordhash() public {
string[] memory _subdomain = new string[](2);
_subdomain[0] = "hello";
_subdomain[1] = "world";
string[] memory _subdomains = new string[](2);
_subdomains[0] = "hello";
_subdomains[1] = "world";
bytes[] memory _name = new bytes[](2);
_name[0] = "domain";
_name[1] = "eth";
Expand All @@ -471,10 +465,10 @@ contract CCIP2ETHTest is Test {
ENS.setOwner(_node, EOA);
bytes memory _recordhash =
hex"e501017200240801122008dd085b86d16226791544f4628c4efc0936c69221fef17dfac843d9713233bb";
ccip2eth.setDeepSubRecordhash(_node, _subdomain, _recordhash);
ccip2eth.setDeepSubRecordhash(_node, _subdomains, _recordhash);
vm.expectRevert(abi.encodeWithSelector(CCIP2ETH.NotAuthorised.selector, "NOT_APPROVED"));
vm.prank(address(0xc0ffee));
ccip2eth.setDeepSubRecordhash(_node, _subdomain, _recordhash);
ccip2eth.setDeepSubRecordhash(_node, _subdomains, _recordhash);
_encoded;
}
}
Expand Down

0 comments on commit 1e31088

Please sign in to comment.