-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from ensdomains/staging
Sync staging with mainnet
- Loading branch information
Showing
88 changed files
with
21,611 additions
and
1,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
contracts/dnsregistrar/mocks/DummyNonCCIPAwareResolver.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
import "../OffchainDNSResolver.sol"; | ||
import "../../resolvers/profiles/IExtendedResolver.sol"; | ||
|
||
contract DummyNonCCIPAwareResolver is IExtendedResolver, ERC165 { | ||
OffchainDNSResolver dnsResolver; | ||
|
||
constructor(OffchainDNSResolver _dnsResolver) { | ||
dnsResolver = _dnsResolver; | ||
} | ||
|
||
function supportsInterface( | ||
bytes4 interfaceId | ||
) public view virtual override returns (bool) { | ||
return | ||
interfaceId == type(IExtendedResolver).interfaceId || | ||
super.supportsInterface(interfaceId); | ||
} | ||
|
||
function resolve( | ||
bytes calldata /* name */, | ||
bytes calldata data | ||
) external view returns (bytes memory) { | ||
string[] memory urls = new string[](1); | ||
urls[0] = "https://example.com/"; | ||
revert OffchainLookup( | ||
address(dnsResolver), | ||
urls, | ||
data, | ||
OffchainDNSResolver.resolveCallback.selector, | ||
data | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
pragma solidity ^0.8.4; | ||
|
||
import "../../dnssec-oracle/BytesUtils.sol"; | ||
import "../RecordParser.sol"; | ||
|
||
contract DummyParser { | ||
using BytesUtils for bytes; | ||
|
||
// parse data in format: name;key1=value1 key2=value2;url | ||
function parseData( | ||
bytes memory data, | ||
uint256 kvCount | ||
) | ||
external | ||
pure | ||
returns ( | ||
string memory name, | ||
string[] memory keys, | ||
string[] memory values, | ||
string memory url | ||
) | ||
{ | ||
uint256 len = data.length; | ||
// retrieve name | ||
uint256 sep1 = data.find(0, len, ";"); | ||
name = string(data.substring(0, sep1)); | ||
|
||
// retrieve url | ||
uint256 sep2 = data.find(sep1 + 1, len - sep1, ";"); | ||
url = string(data.substring(sep2 + 1, len - sep2 - 1)); | ||
|
||
keys = new string[](kvCount); | ||
values = new string[](kvCount); | ||
// retrieve keys and values | ||
uint256 offset = sep1 + 1; | ||
for (uint256 i; i < kvCount && offset < len; i++) { | ||
( | ||
bytes memory key, | ||
bytes memory val, | ||
uint256 nextOffset | ||
) = RecordParser.readKeyValue(data, offset, sep2 - offset); | ||
keys[i] = string(key); | ||
values[i] = string(val); | ||
offset = nextOffset; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
import "../../resolvers/profiles/IExtendedDNSResolver.sol"; | ||
import "../../resolvers/profiles/IAddressResolver.sol"; | ||
import "../../resolvers/profiles/IAddrResolver.sol"; | ||
import "../../utils/HexUtils.sol"; | ||
|
||
contract ExtendedDNSResolver is IExtendedDNSResolver, IERC165 { | ||
using HexUtils for *; | ||
|
||
uint256 private constant COIN_TYPE_ETH = 60; | ||
|
||
error NotImplemented(); | ||
error InvalidAddressFormat(); | ||
|
||
function supportsInterface( | ||
bytes4 interfaceId | ||
) external view virtual override returns (bool) { | ||
return interfaceId == type(IExtendedDNSResolver).interfaceId; | ||
} | ||
|
||
function resolve( | ||
bytes calldata /* name */, | ||
bytes calldata data, | ||
bytes calldata context | ||
) external pure override returns (bytes memory) { | ||
bytes4 selector = bytes4(data); | ||
if ( | ||
selector == IAddrResolver.addr.selector || | ||
selector == IAddressResolver.addr.selector | ||
) { | ||
if (selector == IAddressResolver.addr.selector) { | ||
(, uint256 coinType) = abi.decode(data[4:], (bytes32, uint256)); | ||
if (coinType != COIN_TYPE_ETH) return abi.encode(""); | ||
} | ||
(address record, bool valid) = context.hexToAddress( | ||
2, | ||
context.length | ||
); | ||
if (!valid) revert InvalidAddressFormat(); | ||
return abi.encode(record); | ||
} | ||
revert NotImplemented(); | ||
} | ||
} |
Oops, something went wrong.