Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Review of #40 #41

Merged
merged 25 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c5d6a7a
README update
sshmatrix Jul 18, 2023
c827465
Purge masterhash()
sshmatrix Jul 18, 2023
cc20ffe
README.md update
sshmatrix Jul 19, 2023
e61e9f7
README.md update: 2
sshmatrix Jul 19, 2023
5e2eae6
Reinstate signedRedirect() & ownerhash[]
sshmatrix Jul 19, 2023
ea7b34f
Merge branch 'main' into sshmatrix
sshmatrix Jul 19, 2023
c03c0b6
some more NatSpec
sshmatrix Jul 19, 2023
755925f
Goerli-v4: 0x4b9A4521442485ad7e1b25295125240b5f3F5aaC
sshmatrix Jul 19, 2023
f3b1404
Remove redundant parts; more natSpec
sshmatrix Jul 19, 2023
66511e0
Merge branch 'main' into sshmatrix
sshmatrix Jul 19, 2023
26387ca
update ownerhash[addr] to accept keccak(addr)
sshmatrix Jul 19, 2023
4c6274f
Merge branch 'main' into sshmatrix
sshmatrix Jul 19, 2023
6d747a2
natSpec for GatewayManager
sshmatrix Jul 19, 2023
6a5526a
Mainnet: 0x57532d78FfBcC6ac5534A9b39899C7eC89082CdA
sshmatrix Jul 23, 2023
da31ea1
Merge branch 'main' into sshmatrix
sshmatrix Jul 23, 2023
e74ded2
Fixes for bugs in v1-beta
sshmatrix Jul 26, 2023
b8cb9f9
Fixes for bugs in v1-beta (#34)
sshmatrix Jul 26, 2023
41d4fc5
Some natSpec and fix for avatar/contenthash
sshmatrix Jul 31, 2023
86227e3
Updated Fixes in v1.0.0-beta (#36)
sshmatrix Jul 31, 2023
6f55ddc
Fix error in test.yml
sshmatrix Aug 1, 2023
e8d969e
Merge branch 'sshmatrix' into play
sshmatrix Aug 1, 2023
125bad4
Fix errors in test.yml (#38)
sshmatrix Aug 1, 2023
971afa6
Review of #40
sshmatrix Aug 14, 2023
8b4df64
Merge Review for #40 from 'play' to 'sshmatrix'
sshmatrix Aug 14, 2023
fdc3718
Merge branch 'main' into sshmatrix
sshmatrix Aug 14, 2023
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: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ jobs:
with:
branch: main
force: true
github_token: ${{ secrets.TOKEN }}
github_token: ${{ secrets.TOKEN }}
4 changes: 3 additions & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ contract CCIP2ETHDeploy is Script {
function run() external {
vm.startBroadcast();
GatewayManager manager = new GatewayManager();
new CCIP2ETH(address(manager));
//uint256 ChainID = uint256(5);
//require(ChainID == uint256(1), "WARNING: Deploying with Goerli ChainID. Please double check [!]"); // Comment this for Goerli deploy
new CCIP2ETH(address(manager), "5");
vm.stopBroadcast();
}
}
321 changes: 199 additions & 122 deletions src/CCIP2ETH.sol

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions src/GatewayManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ contract GatewayManager is iERC173, iGatewayManager {

/// @dev - Errors
error ContenthashNotImplemented(bytes1 _type);
error InvalidRequest(string _msg);
error NotImplemented(bytes4 _func);
error InvalidRequest(string _message);
error UnimplementedFeature(bytes4 func);

/// @dev - Contract owner/multisig address
address public owner;
Expand Down Expand Up @@ -68,11 +68,12 @@ contract GatewayManager is iERC173, iGatewayManager {
view
returns (string[] memory gateways)
{
/// @dev Filter recordhash vs. web2 gateway
if (_recordhash.length == 32) {
// ipns short
// Short IPNS hash
_recordhash = abi.encodePacked(hex"e5010172002408011220", _recordhash);
} else if (iGatewayManager(this).isWeb2(_recordhash)) {
//https://
// Web2 fallback
gateways = new string[](1);
gateways[0] = string.concat(string(_recordhash), _path, ".json?t={data}");
return gateways;
Expand Down Expand Up @@ -111,7 +112,7 @@ contract GatewayManager is iERC173, iGatewayManager {
} else if (_prefix == bytes1("b")) {
_fullPath = string.concat("/ipfs/", string(_recordhash), _path, ".json?t={data}");
} else {
revert InvalidRequest("UNSUPPORTED_RECORDHASH");
revert InvalidRequest("BAD_RECORDHASH");
}
while (i < len) {
seed = uint256(keccak256(abi.encodePacked(block.number * i, seed)));
Expand All @@ -127,10 +128,14 @@ contract GatewayManager is iERC173, iGatewayManager {
this;
response;
extradata;
revert NotImplemented(iGatewayManager.__fallback.selector);
revert UnimplementedFeature(iGatewayManager.__fallback.selector);
}

// support managed web2 gateway
/**
* @dev Checks if recordhash is a web2 gateway
* @param _recordhash - Recordhash to check
* @return - Bool
*/
function isWeb2(bytes calldata _recordhash) external pure returns (bool) {
return (bytes8(_recordhash[:8]) == bytes8("https://"));
}
Expand All @@ -155,15 +160,17 @@ contract GatewayManager is iERC173, iGatewayManager {
} else if (func == iResolver.ABI.selector) {
_jsonPath = string.concat("abi/", uintToString(abi.decode(data[36:], (uint256))));
} else if (func == iResolver.dnsRecord.selector || func == iOverloadResolver.dnsRecord.selector) {
// e.g. .well-known/eth/domain/dns/<record>.json
uint256 resource;
if (data.length == 100) {
(resource) = abi.decode(data[68:], (uint256));
// 4 + 32 + 32 + 32 = 100
(resource) = abi.decode(data[68:], (uint256)); // Expect uint16
} else {
(,, resource) = abi.decode(data[4:], (bytes32, bytes, uint256));
}
_jsonPath = string.concat("dns/", uintToString(resource));
} else {
revert NotImplemented(func);
revert UnimplementedFeature(func);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/Interface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface iCCIP2ETH is iENSIP10 {
function redirectService(bytes calldata _encoded, bytes calldata _requested)
external
view
returns (bytes4 _selector, bytes32 _namehash, bytes memory _redirectRequest, string memory domain);
returns (bytes4 _selector, bytes32 _namehash, bytes memory _redirectRequest, string memory _domain);
function setDeepSubRecordhash(bytes32 _node, string[] memory _subdomains, bytes calldata _recordhash)
external
payable;
Expand Down Expand Up @@ -98,18 +98,18 @@ interface iToken {
}

// Note - Owner = Owner of domain.eth
// Note - Manager = On-/Off-chain address approved by Owner
// Note - Manager = On-/Off-Chain address approved by Owner
// Note - Signer = Record signer
interface iCallbackType {
function signedRecord(
address recordSigner, // Owner OR On-chain Manager OR Off-chain Manager
address recordSigner, // Owner OR On-Chain Manager OR Off-Chain Manager
bytes memory recordSignature, // Signature from signer for result value
bytes memory approvedSignature, // bytes length >0 & <64 IF signer is owner or on-chain approved manager
bytes memory result // ABI-encoded result
) external view returns (bytes memory);

function signedDAppService(
address recordSigner, // Owner OR On-chain Manager OR Off-chain Manager
function signedRedirect(
address recordSigner, // Owner OR On-Chain Manager OR Off-Chain Manager
bytes memory recordSignature, // Signature from signer for redirect value
bytes memory approvedSignature, // bytes length >0 & <64 IF signer is owner or on-chain approved manager
bytes memory redirect // DNS-encoded sub/domain.eth to redirect
Expand Down
Loading
Loading