diff --git a/bun.lockb b/bun.lockb index c48dfd25..98942d2a 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/deploy/dnsregistrar/00_deploy_offchain_dns_resolver.ts b/deploy/dnsregistrar/00_deploy_offchain_dns_resolver.ts index f9147e27..64e0a644 100644 --- a/deploy/dnsregistrar/00_deploy_offchain_dns_resolver.ts +++ b/deploy/dnsregistrar/00_deploy_offchain_dns_resolver.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/dnsregistrar/05_deploy_public_suffix_list.ts b/deploy/dnsregistrar/05_deploy_public_suffix_list.ts index 165a5c8b..473b1b90 100644 --- a/deploy/dnsregistrar/05_deploy_public_suffix_list.ts +++ b/deploy/dnsregistrar/05_deploy_public_suffix_list.ts @@ -1,6 +1,6 @@ import { ethers } from 'hardhat' import packet from 'dns-packet' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' function encodeName(name: string) { diff --git a/deploy/dnsregistrar/10_deploy_dnsregistrar.ts b/deploy/dnsregistrar/10_deploy_dnsregistrar.ts index d7c8ed21..03df73ad 100644 --- a/deploy/dnsregistrar/10_deploy_dnsregistrar.ts +++ b/deploy/dnsregistrar/10_deploy_dnsregistrar.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/dnsregistrar/20_set_tlds.ts b/deploy/dnsregistrar/20_set_tlds.ts index fa6fc2f7..14a69901 100644 --- a/deploy/dnsregistrar/20_set_tlds.ts +++ b/deploy/dnsregistrar/20_set_tlds.ts @@ -1,7 +1,7 @@ import { namehash } from 'ethers/lib/utils' import { ethers } from 'hardhat' import packet from 'dns-packet' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' function encodeName(name: string) { diff --git a/deploy/dnssec-oracle/00_deploy_algorithms.ts b/deploy/dnssec-oracle/00_deploy_algorithms.ts index ebe60f1b..205d5eef 100644 --- a/deploy/dnssec-oracle/00_deploy_algorithms.ts +++ b/deploy/dnssec-oracle/00_deploy_algorithms.ts @@ -1,4 +1,4 @@ -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/dnssec-oracle/00_deploy_digests.ts b/deploy/dnssec-oracle/00_deploy_digests.ts index abf0ff3a..b634f7cc 100644 --- a/deploy/dnssec-oracle/00_deploy_digests.ts +++ b/deploy/dnssec-oracle/00_deploy_digests.ts @@ -1,4 +1,4 @@ -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/dnssec-oracle/10_deploy_oracle.ts b/deploy/dnssec-oracle/10_deploy_oracle.ts index 9ec08c1a..9684103e 100644 --- a/deploy/dnssec-oracle/10_deploy_oracle.ts +++ b/deploy/dnssec-oracle/10_deploy_oracle.ts @@ -1,6 +1,6 @@ import packet from 'dns-packet' import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const realAnchors = [ diff --git a/deploy/ethregistrar/00_deploy_base_registrar_implementation.ts b/deploy/ethregistrar/00_deploy_base_registrar_implementation.ts index c2e24c51..2f1261d5 100644 --- a/deploy/ethregistrar/00_deploy_base_registrar_implementation.ts +++ b/deploy/ethregistrar/00_deploy_base_registrar_implementation.ts @@ -1,8 +1,8 @@ -import namehash from 'eth-ens-namehash' import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' import { keccak256 } from 'js-sha3' +import { namehash } from 'viem/ens' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { getNamedAccounts, deployments, network } = hre @@ -17,7 +17,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const deployArgs = { from: deployer, - args: [registry.address, namehash.hash('eth')], + args: [registry.address, namehash('eth')], log: true, } diff --git a/deploy/ethregistrar/00_setup_base_registrar.ts b/deploy/ethregistrar/00_setup_base_registrar.ts index 0bb558ff..9aedb367 100644 --- a/deploy/ethregistrar/00_setup_base_registrar.ts +++ b/deploy/ethregistrar/00_setup_base_registrar.ts @@ -1,4 +1,3 @@ -import namehash from 'eth-ens-namehash' import { ethers } from 'hardhat' import { DeployFunction } from 'hardhat-deploy/types' import { HardhatRuntimeEnvironment } from 'hardhat/types' diff --git a/deploy/ethregistrar/01_deploy_exponential_premium_price_oracle.ts b/deploy/ethregistrar/01_deploy_exponential_premium_price_oracle.ts index 0d4b3d85..3fc84369 100644 --- a/deploy/ethregistrar/01_deploy_exponential_premium_price_oracle.ts +++ b/deploy/ethregistrar/01_deploy_exponential_premium_price_oracle.ts @@ -1,4 +1,4 @@ -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/ethregistrar/02_deploy_legacy_eth_registrar_controller.ts b/deploy/ethregistrar/02_deploy_legacy_eth_registrar_controller.ts index e55e4a35..249e24c1 100644 --- a/deploy/ethregistrar/02_deploy_legacy_eth_registrar_controller.ts +++ b/deploy/ethregistrar/02_deploy_legacy_eth_registrar_controller.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/ethregistrar/03_deploy_eth_registrar_controller.ts b/deploy/ethregistrar/03_deploy_eth_registrar_controller.ts index 4db8768b..b766e2c3 100644 --- a/deploy/ethregistrar/03_deploy_eth_registrar_controller.ts +++ b/deploy/ethregistrar/03_deploy_eth_registrar_controller.ts @@ -1,6 +1,6 @@ import { Interface } from 'ethers/lib/utils' import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const { makeInterfaceId } = require('@openzeppelin/test-helpers') diff --git a/deploy/ethregistrar/04_deploy_bulk_renewal.ts b/deploy/ethregistrar/04_deploy_bulk_renewal.ts index 8fafecc1..130761c7 100644 --- a/deploy/ethregistrar/04_deploy_bulk_renewal.ts +++ b/deploy/ethregistrar/04_deploy_bulk_renewal.ts @@ -1,6 +1,6 @@ import { Interface } from 'ethers/lib/utils' import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const { makeInterfaceId } = require('@openzeppelin/test-helpers') diff --git a/deploy/registry/00_deploy_registry.ts b/deploy/registry/00_deploy_registry.ts index fb24b799..31759982 100644 --- a/deploy/registry/00_deploy_registry.ts +++ b/deploy/registry/00_deploy_registry.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const ZERO_HASH = diff --git a/deploy/registry/01_deploy_reverse_registrar.ts b/deploy/registry/01_deploy_reverse_registrar.ts index deeb1ee9..0a9ec8b6 100644 --- a/deploy/registry/01_deploy_reverse_registrar.ts +++ b/deploy/registry/01_deploy_reverse_registrar.ts @@ -1,6 +1,6 @@ import { namehash } from 'ethers/lib/utils' import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' import { keccak256 } from 'js-sha3' diff --git a/deploy/resolvers/00_deploy_eth_owned_resolver.ts b/deploy/resolvers/00_deploy_eth_owned_resolver.ts index 1a318784..0c2fbba1 100644 --- a/deploy/resolvers/00_deploy_eth_owned_resolver.ts +++ b/deploy/resolvers/00_deploy_eth_owned_resolver.ts @@ -1,4 +1,4 @@ -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' import { ethers } from 'hardhat' diff --git a/deploy/resolvers/00_deploy_extended_dns_resolver.ts b/deploy/resolvers/00_deploy_extended_dns_resolver.ts index 0382e27d..0ecdc5fd 100644 --- a/deploy/resolvers/00_deploy_extended_dns_resolver.ts +++ b/deploy/resolvers/00_deploy_extended_dns_resolver.ts @@ -1,4 +1,4 @@ -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/resolvers/00_deploy_legacy_public_resolver.ts b/deploy/resolvers/00_deploy_legacy_public_resolver.ts index 0b267ccc..6962b688 100644 --- a/deploy/resolvers/00_deploy_legacy_public_resolver.ts +++ b/deploy/resolvers/00_deploy_legacy_public_resolver.ts @@ -1,5 +1,5 @@ import { ethers, network } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/resolvers/00_deploy_public_resolver.ts b/deploy/resolvers/00_deploy_public_resolver.ts index fb089e79..3465f5fa 100644 --- a/deploy/resolvers/00_deploy_public_resolver.ts +++ b/deploy/resolvers/00_deploy_public_resolver.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/root/00_deploy_root.ts b/deploy/root/00_deploy_root.ts index 6b4ebf6d..d2db91f9 100644 --- a/deploy/root/00_deploy_root.ts +++ b/deploy/root/00_deploy_root.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/root/00_setup_root.ts b/deploy/root/00_setup_root.ts index e5a46b7a..7ff601a0 100644 --- a/deploy/root/00_setup_root.ts +++ b/deploy/root/00_setup_root.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const ZERO_HASH = diff --git a/deploy/utils/00_deploy_universal_resolver.ts b/deploy/utils/00_deploy_universal_resolver.ts index 0df6ecd2..96ca70c0 100644 --- a/deploy/utils/00_deploy_universal_resolver.ts +++ b/deploy/utils/00_deploy_universal_resolver.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/wrapper/00_deploy_static_metadata_service.ts b/deploy/wrapper/00_deploy_static_metadata_service.ts index 776475ef..d61bb324 100644 --- a/deploy/wrapper/00_deploy_static_metadata_service.ts +++ b/deploy/wrapper/00_deploy_static_metadata_service.ts @@ -1,4 +1,4 @@ -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/wrapper/01_deploy_name_wrapper.ts b/deploy/wrapper/01_deploy_name_wrapper.ts index 829afd52..8d86335a 100644 --- a/deploy/wrapper/01_deploy_name_wrapper.ts +++ b/deploy/wrapper/01_deploy_name_wrapper.ts @@ -1,6 +1,6 @@ import { Interface } from 'ethers/lib/utils' import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const { makeInterfaceId } = require('@openzeppelin/test-helpers') diff --git a/deploy/wrapper/02_deploy_test_unwrap.ts b/deploy/wrapper/02_deploy_test_unwrap.ts index 81195b48..c6b9cb15 100644 --- a/deploy/wrapper/02_deploy_test_unwrap.ts +++ b/deploy/wrapper/02_deploy_test_unwrap.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat' -import { DeployFunction } from 'hardhat-deploy/types' +import type { DeployFunction } from 'hardhat-deploy/types.js' import { HardhatRuntimeEnvironment } from 'hardhat/types' const TESTNET_WRAPPER_ADDRESSES = { diff --git a/package.json b/package.json index 252b11ba..eb9d0c06 100644 --- a/package.json +++ b/package.json @@ -38,13 +38,12 @@ "chai": "^5.1.1", "dotenv": "^16.4.5", "elliptic-solidity": "^1.0.0", - "envfile": "^6.17.0", "ethereum-waffle": "^3.3.0", "ethers": "^5.6.1", "hardhat": "^2.22.2", "hardhat-abi-exporter": "^2.9.0", "hardhat-contract-sizer": "^2.6.1", - "hardhat-deploy": "^0.11.10", + "hardhat-deploy": "^0.12.4", "hardhat-gas-reporter": "^1.0.4", "husky": "^8.0.0", "prettier": "^2.6.2", @@ -79,5 +78,6 @@ "homepage": "https://github.com/ensdomains/ens-contracts#readme", "volta": { "node": "16.20.2" - } + }, + "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610" } diff --git a/tasks/seed.ts b/tasks/seed.ts index 8011a171..f9ec4a29 100644 --- a/tasks/seed.ts +++ b/tasks/seed.ts @@ -1,10 +1,7 @@ -import fs from 'fs' - -import * as envfile from 'envfile' -import n from 'eth-ens-namehash' +import { namehash } from 'viem/ens' +import * as dotenv from 'dotenv' import { task } from 'hardhat/config' -const namehash = n.hash const labelhash = (utils: any, label: string) => utils.keccak256(utils.toUtf8Bytes(label)) @@ -16,18 +13,13 @@ function getOpenSeaUrl(ethers: any, contract: string, namehashedname: string) { task('seed', 'Creates test subbdomains and wraps them with Namewrapper') .addPositionalParam('name', 'The ENS label to seed subdomains') .setAction(async ({ name }, hre) => { - let parsedFile - try { - parsedFile = envfile.parse(fs.readFileSync('./.env', 'utf8')) - } catch (error: any) { - if (error.code !== 'ENOENT') { - throw error - } - console.warn( - '.env file is empty, fill as in README to complete seed action', - ) - return - } + const { parsed: parsedFile, error } = dotenv.config({ + path: './.env', + encoding: 'utf8', + }) + + if (error) throw error + const ethers = hre.ethers const [deployer] = await ethers.getSigners() const CAN_DO_EVERYTHING = 0 diff --git a/test/dnsregistrar/TestDNSRegistrar.js b/test/dnsregistrar/TestDNSRegistrar.js index 52708cab..ddef1380 100644 --- a/test/dnsregistrar/TestDNSRegistrar.js +++ b/test/dnsregistrar/TestDNSRegistrar.js @@ -4,7 +4,7 @@ const SimplePublixSuffixList = artifacts.require('./SimplePublicSuffixList.sol') const DNSRegistrarContract = artifacts.require('./DNSRegistrar.sol') const PublicResolver = artifacts.require('./PublicResolver.sol') const DNSSECImpl = artifacts.require('./DNSSECImpl') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const utils = require('./Helpers/Utils') const { exceptions } = require('@ensdomains/test-utils') const { assert } = require('chai') @@ -61,7 +61,7 @@ contract('DNSRegistrar', function (accounts) { const ReverseRegistrar = await deploy('ReverseRegistrar', ens.address) await ens.setSubnodeOwner(EMPTY_BYTES32, labelhash('reverse'), accounts[0]) await ens.setSubnodeOwner( - namehash.hash('reverse'), + namehash('reverse'), labelhash('addr'), ReverseRegistrar.address, ) @@ -100,7 +100,7 @@ contract('DNSRegistrar', function (accounts) { from: accounts[1], }) - assert.equal(await ens.owner(namehash.hash('foo.test')), accounts[0]) + assert.equal(await ens.owner(namehash('foo.test')), accounts[0]) }) it('allows claims on names that are not TLDs', async function () { @@ -111,7 +111,7 @@ contract('DNSRegistrar', function (accounts) { await registrar.proveAndClaim(utils.hexEncodeName('foo.co.nz'), proof) - assert.equal(await ens.owner(namehash.hash('foo.co.nz')), accounts[0]) + assert.equal(await ens.owner(namehash('foo.co.nz')), accounts[0]) }) it('allows anyone to update a DNSSEC referenced name', async function () { @@ -126,7 +126,7 @@ contract('DNSRegistrar', function (accounts) { await registrar.proveAndClaim(utils.hexEncodeName('foo.test'), proof) - assert.equal(await ens.owner(namehash.hash('foo.test')), accounts[1]) + assert.equal(await ens.owner(namehash('foo.test')), accounts[1]) }) it('rejects proofs with earlier inceptions', async function () { @@ -173,8 +173,8 @@ contract('DNSRegistrar', function (accounts) { ZERO_ADDRESS, ) - assert.equal(await ens.owner(namehash.hash('foo.test')), accounts[0]) - assert.equal(await ens.resolver(namehash.hash('foo.test')), accounts[1]) + assert.equal(await ens.owner(namehash('foo.test')), accounts[0]) + assert.equal(await ens.resolver(namehash('foo.test')), accounts[1]) }) it('does not allow anyone else to claim and set a resolver', async () => { @@ -214,7 +214,7 @@ contract('DNSRegistrar', function (accounts) { accounts[0], ) - assert.equal(await resolver.addr(namehash.hash('foo.test')), accounts[0]) + assert.equal(await resolver.addr(namehash('foo.test')), accounts[0]) }) it('forbids setting an address if the resolver is not also set', async () => { @@ -309,22 +309,22 @@ contract('DNSRegistrar', function (accounts) { // This is the expected use case. // Using the proof for `alice.test`, can claim `alice.test` - assert.equal(await ens.owner(namehash.hash('alice.test')), ZERO_ADDRESS) + assert.equal(await ens.owner(namehash('alice.test')), ZERO_ADDRESS) await registrar.proveAndClaim( utils.hexEncodeName('alice.test'), proofForAliceDotTest, ) - assert.equal(await ens.owner(namehash.hash('alice.test')), alice) + assert.equal(await ens.owner(namehash('alice.test')), alice) // Now using the same proof for `alice.test`, alice can also claim `foo.test`. Without a proof involving `foo.test` - assert.equal(await ens.owner(namehash.hash('foo.test')), ZERO_ADDRESS) + assert.equal(await ens.owner(namehash('foo.test')), ZERO_ADDRESS) await expect( registrar.proveAndClaim( utils.hexEncodeName('foo.test'), proofForAliceDotTest, ), ).to.be.revertedWith('NoOwnerRecordFound') - assert.equal(await ens.owner(namehash.hash('foo.test')), ZERO_ADDRESS) + assert.equal(await ens.owner(namehash('foo.test')), ZERO_ADDRESS) }) it('cannot takeover claimed DNS domains using unrelated proof', async function () { @@ -338,12 +338,12 @@ contract('DNSRegistrar', function (accounts) { ] // Alice claims her domain - assert.equal(await ens.owner(namehash.hash('alice.test')), ZERO_ADDRESS) + assert.equal(await ens.owner(namehash('alice.test')), ZERO_ADDRESS) await registrar.proveAndClaim( utils.hexEncodeName('alice.test'), proofForAliceDotTest, ) - assert.equal(await ens.owner(namehash.hash('alice.test')), alice) + assert.equal(await ens.owner(namehash('alice.test')), alice) // Build sample proof for a DNS record with name `bob.test` that bob owns const proofForBobDotTest = [ @@ -352,13 +352,13 @@ contract('DNSRegistrar', function (accounts) { ] // Bob claims alice's domain - assert.equal(await ens.owner(namehash.hash('alice.test')), alice) + assert.equal(await ens.owner(namehash('alice.test')), alice) await expect( registrar.proveAndClaim( utils.hexEncodeName('alice.test'), proofForBobDotTest, ), ).to.be.revertedWith('NoOwnerRecordFound') - assert.equal(await ens.owner(namehash.hash('alice.test')), alice) + assert.equal(await ens.owner(namehash('alice.test')), alice) }) }) diff --git a/test/dnsregistrar/TestOffchainDNSResolver.js b/test/dnsregistrar/TestOffchainDNSResolver.js index ef979d62..44354f6f 100644 --- a/test/dnsregistrar/TestOffchainDNSResolver.js +++ b/test/dnsregistrar/TestOffchainDNSResolver.js @@ -18,7 +18,7 @@ const DummyNonCCIPAwareResolver = artifacts.require( './DummyNonCCIPAwareResolver.sol', ) const DNSSECImpl = artifacts.require('./DNSSECImpl') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const utils = require('./Helpers/Utils') const { expect } = require('chai') const { rootKeys, hexEncodeSignedSet } = require('../utils/dnsutils.js') @@ -111,7 +111,7 @@ contract('OffchainDNSResolver', function (accounts) { const DNSGatewayInterface = new ethers.utils.Interface(IDNSGateway.abi) const dnsName = utils.hexEncodeName('test.test') const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash('test.test'), + namehash('test.test'), ).encodeABI() await expect( offchainDNSResolver.resolve(dnsName, callData), @@ -167,10 +167,10 @@ contract('OffchainDNSResolver', function (accounts) { it('handles calls to resolveCallback() with valid DNS TXT records containing an address', async function () { const name = 'test.test' const testAddress = '0xfefeFEFeFEFEFEFEFeFefefefefeFEfEfefefEfe' - await ownedResolver.setAddr(namehash.hash(name), testAddress) + await ownedResolver.setAddr(namehash(name), testAddress) const pr = await PublicResolver.at(offchainDNSResolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() const result = await doDNSResolveCallback( name, @@ -185,10 +185,10 @@ contract('OffchainDNSResolver', function (accounts) { it('handles calls to resolveCallback() with extra data and a legacy resolver', async function () { const name = 'test.test' const testAddress = '0xfefeFEFeFEFEFEFEFeFefefefefeFEfEfefefEfe' - await ownedResolver.setAddr(namehash.hash(name), testAddress) + await ownedResolver.setAddr(namehash(name), testAddress) const pr = await PublicResolver.at(offchainDNSResolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() const result = await doDNSResolveCallback( name, @@ -204,25 +204,22 @@ contract('OffchainDNSResolver', function (accounts) { // Configure dnsresolver.eth to resolve to the ownedResolver so we can use it in the test await root.setSubnodeOwner(ethers.utils.id('eth'), accounts[0]) await ens.setSubnodeOwner( - namehash.hash('eth'), + namehash('eth'), ethers.utils.id('dnsresolver'), accounts[0], ) - await ens.setResolver( - namehash.hash('dnsresolver.eth'), - ownedResolver.address, - ) + await ens.setResolver(namehash('dnsresolver.eth'), ownedResolver.address) await ownedResolver.setAddr( - namehash.hash('dnsresolver.eth'), + namehash('dnsresolver.eth'), ownedResolver.address, ) const name = 'test.test' const testAddress = '0xfefeFEFeFEFEFEFEFeFefefefefeFEfEfefefEfe' - await ownedResolver.setAddr(namehash.hash(name), testAddress) + await ownedResolver.setAddr(namehash(name), testAddress) const pr = await PublicResolver.at(offchainDNSResolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() const result = await doDNSResolveCallback( name, @@ -237,10 +234,10 @@ contract('OffchainDNSResolver', function (accounts) { it('rejects calls to resolveCallback() with an invalid TXT record', async function () { const name = 'test.test' const testAddress = '0xfefeFEFeFEFEFEFEFeFefefefefeFEfEfefefEfe' - await ownedResolver.setAddr(namehash.hash(name), testAddress) + await ownedResolver.setAddr(namehash(name), testAddress) const pr = await PublicResolver.at(offchainDNSResolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() await expect( doDNSResolveCallback(name, ['nonsense'], callData), @@ -250,10 +247,10 @@ contract('OffchainDNSResolver', function (accounts) { it('handles calls to resolveCallback() where the valid TXT record is not the first', async function () { const name = 'test.test' const testAddress = '0xfefeFEFeFEFEFEFEFeFefefefefeFEfEfefefEfe' - await ownedResolver.setAddr(namehash.hash(name), testAddress) + await ownedResolver.setAddr(namehash(name), testAddress) const pr = await PublicResolver.at(offchainDNSResolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() const result = await doDNSResolveCallback( name, @@ -268,10 +265,10 @@ contract('OffchainDNSResolver', function (accounts) { it('respects the first record with a valid resolver', async function () { const name = 'test.test' const testAddress = '0xfefeFEFeFEFEFEFEFeFefefefefeFEfEfefefEfe' - await ownedResolver.setAddr(namehash.hash(name), testAddress) + await ownedResolver.setAddr(namehash(name), testAddress) const pr = await PublicResolver.at(offchainDNSResolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() const result = await doDNSResolveCallback( name, @@ -288,7 +285,7 @@ contract('OffchainDNSResolver', function (accounts) { const resolver = await DummyExtendedDNSSECResolver.new() const pr = await PublicResolver.at(resolver.address) const callData = pr.contract.methods['text']( - namehash.hash(name), + namehash(name), 'test', ).encodeABI() const result = await doDNSResolveCallback( @@ -307,7 +304,7 @@ contract('OffchainDNSResolver', function (accounts) { const resolver = await ExtendedDNSResolver.new() const pr = await PublicResolver.at(resolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() const result = await doDNSResolveCallback( name, @@ -324,7 +321,7 @@ contract('OffchainDNSResolver', function (accounts) { const resolver = await ExtendedDNSResolver.new() const pr = await PublicResolver.at(resolver.address) const callData = pr.contract.methods['addr(bytes32,uint256)']( - namehash.hash(name), + namehash(name), COIN_TYPE_ETH, ).encodeABI() const result = await doDNSResolveCallback( @@ -342,7 +339,7 @@ contract('OffchainDNSResolver', function (accounts) { const resolver = await ExtendedDNSResolver.new() const pr = await PublicResolver.at(resolver.address) const callData = pr.contract.methods['addr(bytes32,uint256)']( - namehash.hash(name), + namehash(name), COIN_TYPE_BTC, ).encodeABI() const result = await doDNSResolveCallback( @@ -359,7 +356,7 @@ contract('OffchainDNSResolver', function (accounts) { const resolver = await ExtendedDNSResolver.new() const pr = await PublicResolver.at(resolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() await expect( doDNSResolveCallback( @@ -374,7 +371,7 @@ contract('OffchainDNSResolver', function (accounts) { const name = 'test.test' const resolver = await DummyLegacyTextResolver.new() const callData = resolver.contract.methods['text']( - namehash.hash(name), + namehash(name), 'test', ).encodeABI() const result = await doDNSResolveCallback( @@ -392,7 +389,7 @@ contract('OffchainDNSResolver', function (accounts) { const pr = await PublicResolver.at(offchainDNSResolver.address) const dnsName = utils.hexEncodeName('test.test') const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() const extraData = ethers.utils.defaultAbiCoder.encode( @@ -443,7 +440,7 @@ contract('OffchainDNSResolver', function (accounts) { const name = 'test.test' const pr = await PublicResolver.at(offchainDNSResolver.address) const callData = pr.contract.methods['addr(bytes32)']( - namehash.hash(name), + namehash(name), ).encodeABI() await expect( doDNSResolveCallback(name, [`ENS1 ${dummyResolver.address}`], callData), diff --git a/test/dnsregistrar/TestUniversalResolverWithDNS.js b/test/dnsregistrar/TestUniversalResolverWithDNS.js index d300b50c..ddcbe7a7 100644 --- a/test/dnsregistrar/TestUniversalResolverWithDNS.js +++ b/test/dnsregistrar/TestUniversalResolverWithDNS.js @@ -1,6 +1,6 @@ const { solidity } = require('ethereum-waffle') const { use, expect } = require('chai') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const { ethers } = require('hardhat') const { dns } = require('../test-utils') @@ -122,7 +122,7 @@ contract('UniversalResolver', function (accounts) { }) beforeEach(async () => { - node = namehash.hash('eth') + node = namehash('eth') ens = await deploy('ENSRegistry') root = await deploy('Root', ens.address) dnssec = await deploy('DNSSECImpl', encodeAnchors(anchors)) @@ -182,7 +182,7 @@ contract('UniversalResolver', function (accounts) { it('should revert OffchainLookup via universalResolver + offchainDNSresolver', async () => { const addrCallData = PublicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('test.test')], + [namehash('test.test')], ) const IDNSGatewayAbi = [ diff --git a/test/ethregistrar/TestBaseRegistrar.js b/test/ethregistrar/TestBaseRegistrar.js index a0c7efaf..3cc4cd46 100644 --- a/test/ethregistrar/TestBaseRegistrar.js +++ b/test/ethregistrar/TestBaseRegistrar.js @@ -3,7 +3,7 @@ const BaseRegistrar = artifacts.require( './registrar/BaseRegistrarImplementation', ) -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const toBN = require('web3-utils').toBN @@ -25,7 +25,7 @@ contract('BaseRegistrar', function (accounts) { before(async () => { ens = await ENS.new() - registrar = await BaseRegistrar.new(ens.address, namehash.hash('eth'), { + registrar = await BaseRegistrar.new(ens.address, namehash('eth'), { from: ownerAccount, }) await registrar.addController(controllerAccount, { from: ownerAccount }) @@ -40,10 +40,7 @@ contract('BaseRegistrar', function (accounts) { { from: controllerAccount }, ) var block = await web3.eth.getBlock(tx.receipt.blockHash) - assert.equal( - await ens.owner(namehash.hash('newname.eth')), - registrantAccount, - ) + assert.equal(await ens.owner(namehash('newname.eth')), registrantAccount) assert.equal(await registrar.ownerOf(sha3('newname')), registrantAccount) assert.equal( (await registrar.nameExpires(sha3('newname'))).toNumber(), @@ -59,7 +56,7 @@ contract('BaseRegistrar', function (accounts) { { from: controllerAccount }, ) var block = await web3.eth.getBlock(tx.receipt.blockHash) - assert.equal(await ens.owner(namehash.hash('silentname.eth')), ZERO_ADDRESS) + assert.equal(await ens.owner(namehash('silentname.eth')), ZERO_ADDRESS) assert.equal(await registrar.ownerOf(sha3('silentname')), registrantAccount) assert.equal( (await registrar.nameExpires(sha3('silentname'))).toNumber(), @@ -107,20 +104,13 @@ contract('BaseRegistrar', function (accounts) { it('should permit the owner to reclaim a name', async () => { await ens.setSubnodeOwner(ZERO_HASH, sha3('eth'), accounts[0]) - await ens.setSubnodeOwner( - namehash.hash('eth'), - sha3('newname'), - ZERO_ADDRESS, - ) - assert.equal(await ens.owner(namehash.hash('newname.eth')), ZERO_ADDRESS) + await ens.setSubnodeOwner(namehash('eth'), sha3('newname'), ZERO_ADDRESS) + assert.equal(await ens.owner(namehash('newname.eth')), ZERO_ADDRESS) await ens.setSubnodeOwner(ZERO_HASH, sha3('eth'), registrar.address) await registrar.reclaim(sha3('newname'), registrantAccount, { from: registrantAccount, }) - assert.equal( - await ens.owner(namehash.hash('newname.eth')), - registrantAccount, - ) + assert.equal(await ens.owner(namehash('newname.eth')), registrantAccount) }) it('should prohibit anyone else from reclaiming a name', async () => { @@ -140,10 +130,7 @@ contract('BaseRegistrar', function (accounts) { ) assert.equal(await registrar.ownerOf(sha3('newname')), otherAccount) // Transfer does not update ENS without a call to reclaim. - assert.equal( - await ens.owner(namehash.hash('newname.eth')), - registrantAccount, - ) + assert.equal(await ens.owner(namehash('newname.eth')), registrantAccount) await registrar.transferFrom( otherAccount, registrantAccount, @@ -202,6 +189,6 @@ contract('BaseRegistrar', function (accounts) { it('should allow the owner to set a resolver address', async () => { await registrar.setResolver(accounts[1], { from: ownerAccount }) - assert.equal(await ens.resolver(namehash.hash('eth')), accounts[1]) + assert.equal(await ens.resolver(namehash('eth')), accounts[1]) }) }) diff --git a/test/ethregistrar/TestBulkRenewal.js b/test/ethregistrar/TestBulkRenewal.js index a62ed6a4..582ffeff 100644 --- a/test/ethregistrar/TestBulkRenewal.js +++ b/test/ethregistrar/TestBulkRenewal.js @@ -9,13 +9,13 @@ const NameWrapper = artifacts.require('./wrapper/NameWrapper.sol') const { deploy } = require('../test-utils/contracts') const { EMPTY_BYTES32: EMPTY_BYTES } = require('../test-utils/constants') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const toBN = require('web3-utils').toBN const { exceptions } = require('../test-utils') const ETH_LABEL = sha3('eth') -const ETH_NAMEHASH = namehash.hash('eth') +const ETH_NAMEHASH = namehash('eth') contract('BulkRenewal', function (accounts) { let ens @@ -35,7 +35,7 @@ contract('BulkRenewal', function (accounts) { // Create a registry ens = await ENS.new() // Create a base registrar - baseRegistrar = await BaseRegistrar.new(ens.address, namehash.hash('eth'), { + baseRegistrar = await BaseRegistrar.new(ens.address, namehash('eth'), { from: ownerAccount, }) @@ -44,7 +44,7 @@ contract('BulkRenewal', function (accounts) { await ens.setSubnodeOwner(EMPTY_BYTES, sha3('reverse'), accounts[0]) await ens.setSubnodeOwner( - namehash.hash('reverse'), + namehash('reverse'), sha3('addr'), reverseRegistrar.address, ) diff --git a/test/ethregistrar/TestExponentialPremiumPriceOracle.js b/test/ethregistrar/TestExponentialPremiumPriceOracle.js index d84145d4..50caf26c 100644 --- a/test/ethregistrar/TestExponentialPremiumPriceOracle.js +++ b/test/ethregistrar/TestExponentialPremiumPriceOracle.js @@ -1,5 +1,5 @@ const { expect } = require('chai') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const toBN = require('web3-utils').toBN @@ -26,7 +26,7 @@ contract('ExponentialPricePremiumOracle', function (accounts) { before(async () => { ens = await ENS.new() - registrar = await BaseRegistrar.new(ens.address, namehash.hash('eth')) + registrar = await BaseRegistrar.new(ens.address, namehash('eth')) await ens.setSubnodeOwner('0x0', sha3('eth'), registrar.address) await registrar.addController(accounts[0]) diff --git a/test/ethregistrar/TestLinearPremiumPriceOracle.js b/test/ethregistrar/TestLinearPremiumPriceOracle.js index 3925677e..4b0557d4 100644 --- a/test/ethregistrar/TestLinearPremiumPriceOracle.js +++ b/test/ethregistrar/TestLinearPremiumPriceOracle.js @@ -3,7 +3,7 @@ const BaseRegistrar = artifacts.require('./BaseRegistrarImplementation') const DummyOracle = artifacts.require('./DummyOracle') const LinearPremiumPriceOracle = artifacts.require('./LinearPremiumPriceOracle') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const toBN = require('web3-utils').toBN @@ -14,7 +14,7 @@ contract('LinearPremiumPriceOracle', function (accounts) { before(async () => { ens = await ENS.new() - registrar = await BaseRegistrar.new(ens.address, namehash.hash('eth')) + registrar = await BaseRegistrar.new(ens.address, namehash('eth')) await ens.setSubnodeOwner('0x0', sha3('eth'), registrar.address) await registrar.addController(accounts[0]) diff --git a/test/ethregistrar/TestStaticBulkRenewal.js b/test/ethregistrar/TestStaticBulkRenewal.js index 3730c8be..d3c8d5d7 100644 --- a/test/ethregistrar/TestStaticBulkRenewal.js +++ b/test/ethregistrar/TestStaticBulkRenewal.js @@ -9,13 +9,13 @@ const NameWrapper = artifacts.require('./wrapper/NameWrapper.sol') const { deploy } = require('../test-utils/contracts') const { EMPTY_BYTES32: EMPTY_BYTES } = require('../test-utils/constants') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const toBN = require('web3-utils').toBN const { exceptions } = require('../test-utils') const ETH_LABEL = sha3('eth') -const ETH_NAMEHASH = namehash.hash('eth') +const ETH_NAMEHASH = namehash('eth') contract('StaticBulkRenewal', function (accounts) { let ens @@ -35,7 +35,7 @@ contract('StaticBulkRenewal', function (accounts) { // Create a registry ens = await ENS.new() // Create a base registrar - baseRegistrar = await BaseRegistrar.new(ens.address, namehash.hash('eth'), { + baseRegistrar = await BaseRegistrar.new(ens.address, namehash('eth'), { from: ownerAccount, }) @@ -44,7 +44,7 @@ contract('StaticBulkRenewal', function (accounts) { await ens.setSubnodeOwner(EMPTY_BYTES, sha3('reverse'), accounts[0]) await ens.setSubnodeOwner( - namehash.hash('reverse'), + namehash('reverse'), sha3('addr'), reverseRegistrar.address, ) diff --git a/test/registry/TestENS.js b/test/registry/TestENS.js index a3a338e7..f951b98b 100644 --- a/test/registry/TestENS.js +++ b/test/registry/TestENS.js @@ -1,4 +1,4 @@ -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const { exceptions } = require('../test-utils') @@ -86,7 +86,7 @@ contracts.forEach(function ([ENS, lang]) { from: accounts[0], }) - assert.equal(await ens.owner(namehash.hash('eth')), accounts[1]) + assert.equal(await ens.owner(namehash('eth')), accounts[1]) assert.equal(result.logs.length, 1) let args = result.logs[0].args diff --git a/test/registry/TestENSRegistryWithFallback.js b/test/registry/TestENSRegistryWithFallback.js index 6ab49508..38f1b143 100644 --- a/test/registry/TestENSRegistryWithFallback.js +++ b/test/registry/TestENSRegistryWithFallback.js @@ -1,4 +1,4 @@ -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const ENS = artifacts.require('ENSRegistryWithFallback.sol') @@ -35,7 +35,7 @@ contract('ENSRegistryWithFallback', function (accounts) { { from: accounts[0] }, ) - let hash = namehash.hash('test') + let hash = namehash('test') assert.equal(await ens.owner(hash), accounts[1]) assert.equal(await ens.resolver(hash), accounts[2]) assert.equal((await ens.ttl(hash)).toNumber(), 3600) @@ -48,7 +48,7 @@ contract('ENSRegistryWithFallback', function (accounts) { }) describe('fallback', async () => { - let hash = namehash.hash('eth') + let hash = namehash('eth') beforeEach(async () => { await old.setSubnodeOwner('0x0', sha3('eth'), accounts[0], { @@ -57,7 +57,7 @@ contract('ENSRegistryWithFallback', function (accounts) { }) it('should use fallback ttl if owner not set', async () => { - let hash = namehash.hash('eth') + let hash = namehash('eth') await old.setSubnodeOwner('0x0', sha3('eth'), accounts[0], { from: accounts[0], }) diff --git a/test/registry/TestFIFSRegistrar.js b/test/registry/TestFIFSRegistrar.js index 098fc334..a0057408 100644 --- a/test/registry/TestFIFSRegistrar.js +++ b/test/registry/TestFIFSRegistrar.js @@ -3,7 +3,7 @@ const ENS = artifacts.require('./registry/ENSRegistry.sol') const { exceptions } = require('../test-utils') const sha3 = require('web3-utils').sha3 -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') contract('FIFSRegistrar', function (accounts) { let registrar, ens @@ -18,7 +18,7 @@ contract('FIFSRegistrar', function (accounts) { it('should allow registration of names', async () => { await registrar.register(sha3('eth'), accounts[0], { from: accounts[0] }) assert.equal(await ens.owner('0x0'), registrar.address) - assert.equal(await ens.owner(namehash.hash('eth')), accounts[0]) + assert.equal(await ens.owner(namehash('eth')), accounts[0]) }) describe('transferring names', async () => { @@ -28,7 +28,7 @@ contract('FIFSRegistrar', function (accounts) { it('should allow transferring name to your own', async () => { await registrar.register(sha3('eth'), accounts[1], { from: accounts[0] }) - assert.equal(await ens.owner(namehash.hash('eth')), accounts[1]) + assert.equal(await ens.owner(namehash('eth')), accounts[1]) }) it('forbids transferring the name you do not own', async () => { diff --git a/test/registry/TestTestRegistrar.js b/test/registry/TestTestRegistrar.js index 3c4f4826..99e4e815 100644 --- a/test/registry/TestTestRegistrar.js +++ b/test/registry/TestTestRegistrar.js @@ -2,7 +2,7 @@ const TestRegistrar = artifacts.require('./registry/TestRegistrar.sol') const ENS = artifacts.require('./registry/ENSRegistry.sol') const { exceptions, evm } = require('../test-utils') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 contract('TestRegistrar', function (accounts) { @@ -10,7 +10,7 @@ contract('TestRegistrar', function (accounts) { let registrar, ens beforeEach(async () => { - node = namehash.hash('eth') + node = namehash('eth') ens = await ENS.new() registrar = await TestRegistrar.new(ens.address, '0x0') diff --git a/test/resolvers/TestExtendedDNSResolver.js b/test/resolvers/TestExtendedDNSResolver.js index 0916c19d..58dbddf5 100644 --- a/test/resolvers/TestExtendedDNSResolver.js +++ b/test/resolvers/TestExtendedDNSResolver.js @@ -1,5 +1,5 @@ const ExtendedDNSResolver = artifacts.require('ExtendedDNSResolver.sol') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const { expect } = require('chai') const packet = require('dns-packet') @@ -19,7 +19,7 @@ contract('ExtendedDNSResolver', function (accounts) { }) async function resolve(name, method, args, context) { - const node = namehash.hash(name) + const node = namehash(name) const callData = PublicResolver.interface.encodeFunctionData(method, [ node, ...args, diff --git a/test/resolvers/TestPublicResolver.js b/test/resolvers/TestPublicResolver.js index 5c9a7394..f75ff39d 100644 --- a/test/resolvers/TestPublicResolver.js +++ b/test/resolvers/TestPublicResolver.js @@ -9,7 +9,7 @@ const { } = require('../test-utils/constants') const { expect } = require('chai') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const { exceptions } = require('../test-utils') @@ -24,7 +24,7 @@ contract('PublicResolver', function (accounts) { beforeEach(async () => { signers = await ethers.getSigners() account = await signers[0].getAddress() - node = namehash.hash('eth') + node = namehash('eth') ens = await ENS.new() nameWrapper = await NameWrapper.new() @@ -34,7 +34,7 @@ contract('PublicResolver', function (accounts) { await ens.setSubnodeOwner(ROOT_NODE, labelhash('reverse'), account) await ens.setSubnodeOwner( - namehash.hash('reverse'), + namehash('reverse'), labelhash('addr'), ReverseRegistrar.address, ) @@ -1033,7 +1033,7 @@ contract('PublicResolver', function (accounts) { it('returns 0 when fetching unset interface', async () => { assert.equal( - await resolver.interfaceImplementer(namehash.hash('foo'), '0x12345678'), + await resolver.interfaceImplementer(namehash('foo'), '0x12345678'), '0x0000000000000000000000000000000000000000', ) }) diff --git a/test/reverseRegistrar/TestReverseRegistrar.js b/test/reverseRegistrar/TestReverseRegistrar.js index bb91da0d..4d50fd4c 100644 --- a/test/reverseRegistrar/TestReverseRegistrar.js +++ b/test/reverseRegistrar/TestReverseRegistrar.js @@ -1,4 +1,4 @@ -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('web3-utils').sha3 const PublicResolver = artifacts.require('./resolvers/PublicResolver.sol') const ReverseRegistrar = artifacts.require('./registry/ReverseRegistrar.sol') @@ -36,7 +36,7 @@ contract('ReverseRegistrar', function (accounts) { from: accounts[0], }) await ens.setSubnodeOwner( - namehash.hash('reverse'), + namehash('reverse'), sha3('addr'), registrar.address, { from: accounts[0] }, diff --git a/test/root/TestRoot.js b/test/root/TestRoot.js index 086c2f55..306907f7 100644 --- a/test/root/TestRoot.js +++ b/test/root/TestRoot.js @@ -2,7 +2,7 @@ const Root = artifacts.require('./Root.sol') const ENS = artifacts.require('@ensdomains/ens/contracts/ENSRegistry.sol') const { exceptions, evm } = require('@ensdomains/test-utils') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const sha3 = require('js-sha3').keccak_256 contract('Root', function (accounts) { @@ -12,7 +12,7 @@ contract('Root', function (accounts) { let now = Math.round(new Date().getTime() / 1000) beforeEach(async function () { - node = namehash.hash('eth') + node = namehash('eth') ens = await ENS.new() root = await Root.new(ens.address) diff --git a/test/test-utils/ens.js b/test/test-utils/ens.js index f8109273..56dd99a6 100644 --- a/test/test-utils/ens.js +++ b/test/test-utils/ens.js @@ -2,7 +2,7 @@ const { utils, BigNumber: BN } = ethers const packet = require('dns-packet') const labelhash = (label) => utils.keccak256(utils.toUtf8Bytes(label)) -const namehash = require('eth-ens-namehash').hash +const { namehash } = require('viem/ens') function encodeName(name) { return '0x' + packet.name.encode(name).toString('hex') } diff --git a/test/test-utils/reverse.js b/test/test-utils/reverse.js index 247b778b..c5e62f20 100644 --- a/test/test-utils/reverse.js +++ b/test/test-utils/reverse.js @@ -1,7 +1,7 @@ -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') function getReverseNode(addr) { - return namehash.hash(addr.slice(2).toLowerCase() + '.addr.reverse') + return namehash(addr.slice(2).toLowerCase() + '.addr.reverse') } module.exports = { getReverseNode, diff --git a/test/utils/TestUniversalResolver.js b/test/utils/TestUniversalResolver.js index c805ecfe..7de04d66 100644 --- a/test/utils/TestUniversalResolver.js +++ b/test/utils/TestUniversalResolver.js @@ -1,6 +1,6 @@ const { solidity } = require('ethereum-waffle') const { use, expect } = require('chai') -const namehash = require('eth-ens-namehash') +const { namehash } = require('viem/ens') const { hexDataSlice, concat } = require('ethers/lib/utils') const sha3 = require('web3-utils').sha3 const { Contract } = require('ethers') @@ -58,7 +58,7 @@ contract('UniversalResolver', function (accounts) { }) beforeEach(async () => { - node = namehash.hash('eth') + node = namehash('eth') ens = await deploy('ENSRegistry') nameWrapper = await deploy('DummyNameWrapper') reverseRegistrar = await deploy('ReverseRegistrar', ens.address) @@ -69,7 +69,7 @@ contract('UniversalResolver', function (accounts) { from: accounts[0], }) await ens.setSubnodeOwner( - namehash.hash('reverse'), + namehash('reverse'), sha3('addr'), reverseRegistrar.address, { from: accounts[0] }, @@ -91,52 +91,49 @@ contract('UniversalResolver', function (accounts) { await ens.setSubnodeOwner(EMPTY_BYTES32, sha3('eth'), accounts[0], { from: accounts[0], }) - await ens.setSubnodeOwner(namehash.hash('eth'), sha3('test'), accounts[0], { + await ens.setSubnodeOwner(namehash('eth'), sha3('test'), accounts[0], { from: accounts[0], }) - await ens.setResolver(namehash.hash('test.eth'), publicResolver.address, { + await ens.setResolver(namehash('test.eth'), publicResolver.address, { from: accounts[0], }) - await ens.setSubnodeOwner( - namehash.hash('test.eth'), - sha3('sub'), - accounts[0], - { from: accounts[0] }, - ) - await ens.setResolver(namehash.hash('sub.test.eth'), accounts[1], { + await ens.setSubnodeOwner(namehash('test.eth'), sha3('sub'), accounts[0], { + from: accounts[0], + }) + await ens.setResolver(namehash('sub.test.eth'), accounts[1], { from: accounts[0], }) await publicResolver.functions['setAddr(bytes32,address)']( - namehash.hash('test.eth'), + namehash('test.eth'), accounts[1], { from: accounts[0] }, ) await publicResolver.functions['setText(bytes32,string,string)']( - namehash.hash('test.eth'), + namehash('test.eth'), 'foo', 'bar', { from: accounts[0] }, ) await ens.setSubnodeOwner( - namehash.hash('test.eth'), + namehash('test.eth'), sha3('offchain'), accounts[0], { from: accounts[0] }, ) await ens.setSubnodeOwner( - namehash.hash('test.eth'), + namehash('test.eth'), sha3('no-resolver'), accounts[0], { from: accounts[0] }, ) await ens.setSubnodeOwner( - namehash.hash('test.eth'), + namehash('test.eth'), sha3('revert-resolver'), accounts[0], { from: accounts[0] }, ) await ens.setSubnodeOwner( - namehash.hash('test.eth'), + namehash('test.eth'), sha3('non-contract-resolver'), accounts[0], { from: accounts[0] }, @@ -145,26 +142,23 @@ contract('UniversalResolver', function (accounts) { for (let i = 0; i < 5; i += 1) { const parent = name const label = `sub${i}` - await ens.setSubnodeOwner( - namehash.hash(parent), - sha3(label), - accounts[0], - { from: accounts[0] }, - ) + await ens.setSubnodeOwner(namehash(parent), sha3(label), accounts[0], { + from: accounts[0], + }) name = `${label}.${parent}` } await ens.setResolver( - namehash.hash('offchain.test.eth'), + namehash('offchain.test.eth'), dummyOffchainResolver.address, { from: accounts[0] }, ) await ens.setResolver( - namehash.hash('revert-resolver.test.eth'), + namehash('revert-resolver.test.eth'), dummyRevertResolver.address, { from: accounts[0] }, ) await ens.setResolver( - namehash.hash('non-contract-resolver.test.eth'), + namehash('non-contract-resolver.test.eth'), accounts[0], { from: accounts[0] }, ) @@ -172,10 +166,10 @@ contract('UniversalResolver', function (accounts) { await reverseRegistrar.claim(accounts[0], { from: accounts[0], }) - await ens.setResolver(namehash.hash(reverseNode), publicResolver.address, { + await ens.setResolver(namehash(reverseNode), publicResolver.address, { from: accounts[0], }) - await publicResolver.setName(namehash.hash(reverseNode), 'test.eth') + await publicResolver.setName(namehash(reverseNode), 'test.eth') const oldResolverSigner = await ethers.getSigner(accounts[10]) const _reverseRegistrar = reverseRegistrar.connect(oldResolverSigner) @@ -183,7 +177,7 @@ contract('UniversalResolver', function (accounts) { await _reverseRegistrar.claim(accounts[10]) await _ens.setResolver( - namehash.hash(oldResolverReverseNode), + namehash(oldResolverReverseNode), dummyOldResolver.address, ) }) @@ -248,7 +242,7 @@ contract('UniversalResolver', function (accounts) { it('should resolve a record via legacy methods', async () => { const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('test.eth')], + [namehash('test.eth')], ) const result = await universalResolver['resolve(bytes,bytes)']( @@ -265,7 +259,7 @@ contract('UniversalResolver', function (accounts) { it('should throw if a resolver is not set on the queried name', async () => { const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('no-resolver.test.other')], + [namehash('no-resolver.test.other')], ) await expect( @@ -279,7 +273,7 @@ contract('UniversalResolver', function (accounts) { it('should throw if a resolver is not a contract', async () => { const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('non-contract-resolver.test.eth')], + [namehash('non-contract-resolver.test.eth')], ) await expect( @@ -293,7 +287,7 @@ contract('UniversalResolver', function (accounts) { it('should throw with revert data if resolver reverts', async () => { const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('revert-resolver.test.eth')], + [namehash('revert-resolver.test.eth')], ) try { @@ -323,7 +317,7 @@ contract('UniversalResolver', function (accounts) { it('should throw if a resolver is not set on the queried name, and the found resolver does not support resolve()', async () => { const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('no-resolver.test.eth')], + [namehash('no-resolver.test.eth')], ) await expect( @@ -336,20 +330,15 @@ contract('UniversalResolver', function (accounts) { it('should resolve a record if `supportsInterface` throws', async () => { const legacyResolver = await LegacyResolver.deploy() - await ens.setSubnodeOwner( - namehash.hash('eth'), - sha3('test2'), - accounts[0], - { from: accounts[0] }, - ) - await ens.setResolver( - namehash.hash('test2.eth'), - legacyResolver.address, - { from: accounts[0] }, - ) + await ens.setSubnodeOwner(namehash('eth'), sha3('test2'), accounts[0], { + from: accounts[0], + }) + await ens.setResolver(namehash('test2.eth'), legacyResolver.address, { + from: accounts[0], + }) const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('test.eth')], + [namehash('test.eth')], ) const result = await universalResolver['resolve(bytes,bytes)']( dns.hexEncodeName('test2.eth'), @@ -364,20 +353,15 @@ contract('UniversalResolver', function (accounts) { it('should not run out of gas if calling a non-existent function on a legacy resolver', async () => { const legacyResolver = await LegacyResolver.deploy() - await ens.setSubnodeOwner( - namehash.hash('eth'), - sha3('test2'), - accounts[0], - { from: accounts[0] }, - ) - await ens.setResolver( - namehash.hash('test2.eth'), - legacyResolver.address, - { from: accounts[0] }, - ) + await ens.setSubnodeOwner(namehash('eth'), sha3('test2'), accounts[0], { + from: accounts[0], + }) + await ens.setResolver(namehash('test2.eth'), legacyResolver.address, { + from: accounts[0], + }) const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32,uint256)', - [namehash.hash('test.eth'), 60], + [namehash('test.eth'), 60], ) try { await universalResolver['resolve(bytes,bytes)']( @@ -395,7 +379,7 @@ contract('UniversalResolver', function (accounts) { it('should return a wrapped revert if the resolver reverts with OffchainLookup', async () => { const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('offchain.test.eth')], + [namehash('offchain.test.eth')], ) // OffchainLookup(address sender, string[] urls, bytes callData, bytes4 callbackFunction, bytes extraData) @@ -441,7 +425,7 @@ contract('UniversalResolver', function (accounts) { it('should use custom gateways when specified', async () => { const data = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('offchain.test.eth')], + [namehash('offchain.test.eth')], ) try { await universalResolver['resolve(bytes,bytes,string[])']( @@ -460,7 +444,7 @@ contract('UniversalResolver', function (accounts) { it('should return a wrapped revert with resolve() wrapped calls in extraData when combining onchain and offchain lookups', async () => { const addrData = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('offchain.test.eth')], + [namehash('offchain.test.eth')], ) const onchainDataCall = '0x12345678' @@ -518,11 +502,11 @@ contract('UniversalResolver', function (accounts) { it('should resolve multiple records onchain', async () => { const textData = publicResolver.interface.encodeFunctionData( 'text(bytes32,string)', - [namehash.hash('test.eth'), 'foo'], + [namehash('test.eth'), 'foo'], ) const addrData = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('test.eth')], + [namehash('test.eth')], ) const [[textResultEncoded, addrResultEncoded]] = await universalResolver['resolve(bytes,bytes[])']( @@ -545,11 +529,11 @@ contract('UniversalResolver', function (accounts) { it('should resolve multiple records offchain', async () => { const textData = publicResolver.interface.encodeFunctionData( 'text(bytes32,string)', - [namehash.hash('offchain.test.eth'), 'foo'], + [namehash('offchain.test.eth'), 'foo'], ) const addrData = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('offchain.test.eth')], + [namehash('offchain.test.eth')], ) const callData = batchGateway.encodeFunctionData('query', [ [ @@ -607,7 +591,7 @@ contract('UniversalResolver', function (accounts) { it('should resolve a record via a callback from offchain lookup', async () => { const addrData = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('offchain.test.eth')], + [namehash('offchain.test.eth')], ) const extraData = ethers.utils.defaultAbiCoder.encode( ['bool', 'address', 'string[]', 'bytes', '(bytes4,bytes)[]'], @@ -680,11 +664,11 @@ contract('UniversalResolver', function (accounts) { it('should resolve records via a callback from offchain lookup', async () => { const addrData = publicResolver.interface.encodeFunctionData( 'addr(bytes32)', - [namehash.hash('offchain.test.eth')], + [namehash('offchain.test.eth')], ) const textData = publicResolver.interface.encodeFunctionData( 'text(bytes32,string)', - [namehash.hash('offchain.test.eth'), 'foo'], + [namehash('offchain.test.eth'), 'foo'], ) const extraData = ethers.utils.defaultAbiCoder.encode( ['bool', 'address', 'string[]', 'bytes', '(bytes4,bytes)[]'], @@ -747,7 +731,7 @@ contract('UniversalResolver', function (accounts) { ) const textData = publicResolver.interface.encodeFunctionData( 'text(bytes32,string)', - [namehash.hash('offchain.test.eth'), 'foo'], + [namehash('offchain.test.eth'), 'foo'], ) const extraData = ethers.utils.defaultAbiCoder.encode( ['bool', 'address', 'string[]', 'bytes', '(bytes4,bytes)[]'], @@ -785,11 +769,11 @@ contract('UniversalResolver', function (accounts) { it('should gracefully handle a non-existent function on an offchain resolver', async () => { const addrData = publicResolver.interface.encodeFunctionData( 'addr(bytes32,uint256)', - [namehash.hash('offchain.test.eth'), 60], + [namehash('offchain.test.eth'), 60], ) const textData = publicResolver.interface.encodeFunctionData( 'text(bytes32,string)', - [namehash.hash('offchain.test.eth'), 'foo'], + [namehash('offchain.test.eth'), 'foo'], ) const extraData = ethers.utils.defaultAbiCoder.encode( ['bool', 'address', 'string[]', 'bytes', '(bytes4,bytes)[]'], diff --git a/test/wrapper/BytesUtils.js b/test/wrapper/BytesUtils.js index e5290dbc..035a25b0 100644 --- a/test/wrapper/BytesUtils.js +++ b/test/wrapper/BytesUtils.js @@ -2,7 +2,7 @@ const packet = require('dns-packet') const { expect } = require('chai') const { ethers } = require('hardhat') const { utils, BigNumber: BN } = ethers -const namehash = require('eth-ens-namehash').hash +const { namehash } = require('viem/ens') const NULL_HASH = '0x0000000000000000000000000000000000000000000000000000000000000000' diff --git a/test/wrapper/ERC1155.behaviour.js b/test/wrapper/ERC1155.behaviour.js index 11282d40..5c338955 100644 --- a/test/wrapper/ERC1155.behaviour.js +++ b/test/wrapper/ERC1155.behaviour.js @@ -2,7 +2,7 @@ // Copyright (c) 2016-2020 zOS Global Limited // Portions Copyright (c) 2021 Nick Johnson -const namehash = require('eth-ens-namehash').hash +const { namehash } = require('viem/ens') const { BN, constants, expectEvent } = require('@openzeppelin/test-helpers') const { ZERO_ADDRESS } = constants const { ethers } = require('hardhat') diff --git a/typings-custom/eth-ens-namehash.d.ts b/typings-custom/eth-ens-namehash.d.ts deleted file mode 100644 index f6af2ca9..00000000 --- a/typings-custom/eth-ens-namehash.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'eth-ens-namehash'