-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma solidity ^0.8.4; | ||
|
||
import "../dnssec-oracle/BytesUtils.sol"; | ||
import "./PublicSuffixList.sol"; | ||
|
||
/** | ||
* @dev A public suffix list that treats all TLDs as public suffixes. | ||
*/ | ||
contract TLDPublicSuffixList is PublicSuffixList { | ||
using BytesUtils for bytes; | ||
|
||
function isPublicSuffix( | ||
bytes calldata name | ||
) external view override returns (bool) { | ||
uint256 labellen = name.readUint8(0); | ||
return labellen > 0 && name.readUint8(labellen + 1) == 0; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { ethers } from 'hardhat' | ||
import { DeployFunction } from 'hardhat-deploy/types' | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types' | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { getNamedAccounts, deployments } = hre | ||
const { deploy } = deployments | ||
const { deployer, owner } = await getNamedAccounts() | ||
|
||
await deploy('SimplePublicSuffixList', { | ||
from: deployer, | ||
args: [], | ||
log: true, | ||
}) | ||
const publicSuffixList = await ethers.getContract('SimplePublicSuffixList') | ||
|
||
const suffixList = await ( | ||
await fetch('https://publicsuffix.org/list/public_suffix_list.dat') | ||
).text() | ||
let suffixes = suffixList | ||
.split('\n') | ||
.filter((suffix) => !suffix.startsWith('//') && suffix.trim() != '') | ||
// Right now we're only going to support top-level, non-idna suffixes | ||
suffixes = suffixes.filter((suffix) => suffix.match(/^[a-z0-9]+$/)) | ||
const promises = [] | ||
for (let i = 0; i < suffixes.length; i += 100) { | ||
const batch = suffixes | ||
.slice(i, i + 100) | ||
.map((suffix) => ethers.utils.toUtf8Bytes(suffix)) | ||
promises.push(publicSuffixList.addPublicSuffixes(batch)) | ||
} | ||
console.log( | ||
`Waiting on ${promises.length} suffix-setting transactions to complete...`, | ||
) | ||
await Promise.all(promises) | ||
|
||
if (owner !== undefined && owner !== deployer) { | ||
console.log('Transferring ownership to owner account') | ||
await publicSuffixList.transferOwnership(owner) | ||
} | ||
} | ||
|
||
func.tags = ['SimplePublicSuffixList'] | ||
func.dependencies = [] | ||
|
||
export default func |
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