-
Notifications
You must be signed in to change notification settings - Fork 60
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
10 changed files
with
802 additions
and
102 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,120 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
/* eslint-disable no-await-in-loop */ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
const { readFile } = require('fs/promises') | ||
const { resolve } = require('path') | ||
const { labelhash } = require('viem') | ||
|
||
const ensContractsPath = './node_modules/@ensdomains/ens-contracts' | ||
const mainnetArtifactsPath = resolve(ensContractsPath, './deployments/mainnet') | ||
|
||
const constructorArgs = [ | ||
'0x00002b000100000e1000244a5c080249aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb500002b000100000e1000244f660802e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d', | ||
] | ||
|
||
/** | ||
* @param {string} name | ||
*/ | ||
const getMainnetArtifact = async (name) => { | ||
const deployment = JSON.parse( | ||
await readFile(resolve(mainnetArtifactsPath, `${name}.json`), 'utf8'), | ||
) | ||
const artifact = { | ||
_format: 'hh-sol-artifact-1', | ||
contractName: `Legacy${name}`, | ||
abi: deployment.abi, | ||
bytecode: deployment.bytecode, | ||
deployedBytecode: deployment.deployedBytecode, | ||
linkReferences: {}, | ||
deployedLinkReferences: {}, | ||
} | ||
return artifact | ||
} | ||
|
||
/** | ||
* @type {import('hardhat-deploy/types').DeployFunction} | ||
*/ | ||
const func = async function (hre) { | ||
const { getNamedAccounts, deployments } = hre | ||
const { deploy } = deployments | ||
const { deployer, owner } = await getNamedAccounts() | ||
|
||
const { address: legacyDnssecImplAddress } = await deploy( | ||
'LegacyDNSSECImpl', | ||
{ | ||
from: deployer, | ||
args: constructorArgs, | ||
log: true, | ||
contract: await getMainnetArtifact('DNSSECImpl'), | ||
}, | ||
) | ||
|
||
const dnssec = await hre.ethers.getContract('LegacyDNSSECImpl') | ||
|
||
const algorithms = { | ||
5: 'RSASHA1Algorithm', | ||
7: 'RSASHA1Algorithm', | ||
8: 'RSASHA256Algorithm', | ||
13: 'P256SHA256Algorithm', | ||
} | ||
const digests = { | ||
1: 'SHA1Digest', | ||
2: 'SHA256Digest', | ||
} | ||
|
||
const transactions = [] | ||
for (const [id, alg] of Object.entries(algorithms)) { | ||
const { address } = await deployments.get(alg) | ||
if (address !== (await dnssec.algorithms(id))) { | ||
transactions.push(await dnssec.setAlgorithm(id, address)) | ||
} | ||
} | ||
|
||
for (const [id, digest] of Object.entries(digests)) { | ||
const { address } = await deployments.get(digest) | ||
if (address !== (await dnssec.digests(id))) { | ||
transactions.push(await dnssec.setDigest(id, address)) | ||
} | ||
} | ||
|
||
console.log( | ||
`Waiting on ${transactions.length} transactions setting legacy DNSSEC parameters`, | ||
) | ||
await Promise.all(transactions.map((tx) => tx.wait())) | ||
|
||
const root = await hre.ethers.getContract('Root') | ||
const { address: registryAddress } = await hre.ethers.getContract( | ||
'ENSRegistry', | ||
) | ||
const { address: publicSuffixListAddress } = await hre.ethers.getContract( | ||
'TLDPublicSuffixList', | ||
) | ||
|
||
const { address: legacyDnsRegistrarAddress } = await deploy( | ||
'LegacyDNSRegistrar', | ||
{ | ||
from: deployer, | ||
args: [legacyDnssecImplAddress, publicSuffixListAddress, registryAddress], | ||
log: true, | ||
contract: await getMainnetArtifact('DNSRegistrar'), | ||
}, | ||
) | ||
|
||
const tx = await root | ||
.connect(await hre.ethers.getSigner(owner)) | ||
.setController(legacyDnsRegistrarAddress, true) | ||
console.log( | ||
`Setting LegacyDNSRegistrar as controller of Root... (${tx.hash})`, | ||
) | ||
await tx.wait() | ||
|
||
const tx2 = await root | ||
.connect(await hre.ethers.getSigner(owner)) | ||
.setSubnodeOwner(labelhash('xyz'), legacyDnsRegistrarAddress) | ||
console.log(`Setting LegacyDNSRegistrar as owner of xyz... (${tx2.hash})`) | ||
await tx2.wait() | ||
} | ||
|
||
func.dependencies = ['Root'] | ||
|
||
module.exports = 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
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,73 @@ | ||
export const legacyDnsRegistrarProveAndClaimSnippet = [ | ||
{ | ||
inputs: [ | ||
{ | ||
name: 'name', | ||
type: 'bytes', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
name: 'rrset', | ||
type: 'bytes', | ||
}, | ||
{ | ||
name: 'sig', | ||
type: 'bytes', | ||
}, | ||
], | ||
name: 'input', | ||
type: 'tuple[]', | ||
}, | ||
{ | ||
name: 'proof', | ||
type: 'bytes', | ||
}, | ||
], | ||
name: 'proveAndClaim', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
] as const | ||
|
||
export const legacyDnsRegistrarProveAndClaimWithResolverSnippet = [ | ||
{ | ||
inputs: [ | ||
{ | ||
name: 'name', | ||
type: 'bytes', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
name: 'rrset', | ||
type: 'bytes', | ||
}, | ||
{ | ||
name: 'sig', | ||
type: 'bytes', | ||
}, | ||
], | ||
name: 'input', | ||
type: 'tuple[]', | ||
}, | ||
{ | ||
name: 'proof', | ||
type: 'bytes', | ||
}, | ||
{ | ||
name: 'resolver', | ||
type: 'address', | ||
}, | ||
{ | ||
name: 'addr', | ||
type: 'address', | ||
}, | ||
], | ||
name: 'proveAndClaimWithResolver', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
] as const |
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 @@ | ||
export const legacyDnssecImplRrDataSnippet = [ | ||
{ | ||
inputs: [ | ||
{ | ||
name: 'dnstype', | ||
type: 'uint16', | ||
}, | ||
{ | ||
name: 'name', | ||
type: 'bytes', | ||
}, | ||
], | ||
name: 'rrdata', | ||
outputs: [ | ||
{ | ||
name: '', | ||
type: 'uint32', | ||
}, | ||
{ | ||
name: '', | ||
type: 'uint32', | ||
}, | ||
{ | ||
name: '', | ||
type: 'bytes20', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
] as const | ||
|
||
export const legacyDnssecImplAnchorsSnippet = [ | ||
{ | ||
inputs: [], | ||
name: 'anchors', | ||
outputs: [ | ||
{ | ||
name: '', | ||
type: 'bytes', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
] as const |
Oops, something went wrong.