Skip to content

Commit

Permalink
use new reverseRegistrar
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Apr 26, 2022
1 parent 06df78a commit 657e795
Show file tree
Hide file tree
Showing 45 changed files with 4,697 additions and 1,127 deletions.
121 changes: 121 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"ts-node": "^10.7.0",
"typescript": "^4.6.2"
},
"resolutions": {
"@nomiclabs/hardhat-ethers": "npm:[email protected]"
},
"dependencies": {
"ethers": "^5.6.1"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/ensjs/contracts/ReverseRegistrar.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >0.0.0;
import 'ens-contracts-main/contracts/registry/ReverseRegistrar.sol';
65 changes: 65 additions & 0 deletions packages/ensjs/deploy/02_ReverseRegistrar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { namehash, solidityKeccak256 } from 'ethers/lib/utils'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { ENSRegistry__factory } from '../src/generated/factories/ENSRegistry__factory'
import { Root__factory } from '../src/generated/factories/Root__factory'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre
const { deploy } = deployments

const { deployer } = await getNamedAccounts()

const registryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'

ethers.provider = new ethers.providers.JsonRpcProvider(
'http://localhost:8545',
)

const root = Root__factory.connect(
'0x31e789Eb325aB116997942f7809731197a3dc059',
ethers.provider.getSigner('0xa303ddC620aa7d1390BACcc8A495508B183fab59'),
)

const registry = ENSRegistry__factory.connect(
registryAddress,
ethers.provider.getSigner('0xa303ddC620aa7d1390BACcc8A495508B183fab59'),
)

await deploy('ReverseRegistrar', {
from: deployer,
args: [registryAddress],
})

const reverseRegistrarAddress = (await deployments.get('ReverseRegistrar'))
.address

const tx1 = await root.setSubnodeOwner(
solidityKeccak256(['string'], ['reverse']),
'0xa303ddC620aa7d1390BACcc8A495508B183fab59',
{
from: '0xa303ddC620aa7d1390BACcc8A495508B183fab59',
},
)

await tx1?.wait()

const tx = await registry.setSubnodeOwner(
namehash('reverse'),
solidityKeccak256(['string'], ['addr']),
reverseRegistrarAddress,
{
from: '0xa303ddC620aa7d1390BACcc8A495508B183fab59',
},
)

await tx?.wait()

console.log(
'Deployed ReverseRegistrar, address:',
(await deployments.get('ReverseRegistrar')).address,
)
}

export default func
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre
const { deploy, get } = deployments
const { deploy, get, execute } = deployments

const { deployer } = await getNamedAccounts()

const ReverseRegistrar = await ethers.getContract('ReverseRegistrar')

const registryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'
const controllerAddress = '0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5'
const reverseRegisrarAddress = '0x084b1c3C81545d370f3634392De611CaaBFf8148'
const reverseRegistrarAddress = ReverseRegistrar.address
const wrapperAddress = (await get('NameWrapper')).address

await deploy('PublicResolver', {
Expand All @@ -18,10 +21,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
registryAddress,
wrapperAddress,
controllerAddress,
reverseRegisrarAddress,
reverseRegistrarAddress,
],
})

const tx = await ReverseRegistrar.setDefaultResolver(
(
await get('PublicResolver')
).address,
)
await tx.wait()
console.log(tx)

console.log(
'Deployed PublicResolver, address:',
(await deployments.get('PublicResolver')).address,
Expand Down
1 change: 1 addition & 0 deletions packages/ensjs/ens-test-env.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
network: 'ropsten',
forkRpcUrl: process.env.FORK_RPC_URL,
secretWords: 'test test test test test test test test test test test junk',
unlockedAccounts: ['0xa303ddC620aa7d1390BACcc8A495508B183fab59'],
},
archive: {
subgraphId: 'QmXxAE7Urtv6TPa8o8XmPwLVQNbH6r35hRKHP63udTxTNa',
Expand Down
16 changes: 16 additions & 0 deletions packages/ensjs/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import '@nomiclabs/hardhat-ethers'
import 'dotenv/config'
import 'hardhat-abi-exporter'
import 'hardhat-deploy'
import { HardhatUserConfig } from 'hardhat/config'

Expand Down Expand Up @@ -30,6 +32,20 @@ const config: HardhatUserConfig = {
namedAccounts: {
deployer: 0,
},
abiExporter: {
path: './src/ABIs',
clear: true,
flat: true,
only: [
'StaticMetadataService',
'NameWrapper',
'ReverseRegistrar',
'PublicResolver',
'UniversalResolver',
'DoNotCallOnChainUniversalResolverProxy',
],
except: ['INameWrapper', 'IReverseRegistrar', 'NameResolver'],
},
}

export default config
Loading

0 comments on commit 657e795

Please sign in to comment.