From 97d389f633f6e9f599834eee9396bb324a2f41ae Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 15 Jun 2023 15:28:39 -0700 Subject: [PATCH 01/16] remove redundant comments --- contracts/access/ZNSRoles.sol | 4 +--- contracts/distribution/ZNSRegistrar.sol | 3 --- contracts/registry/ZNSRegistry.sol | 1 - src/deploy.ts | 20 -------------------- test/ZNSRegistry.test.ts | 1 - test/helpers/types.ts | 5 ++--- 6 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 src/deploy.ts diff --git a/contracts/access/ZNSRoles.sol b/contracts/access/ZNSRoles.sol index a6d2facad..9f997dce3 100644 --- a/contracts/access/ZNSRoles.sol +++ b/contracts/access/ZNSRoles.sol @@ -2,15 +2,13 @@ pragma solidity ^0.8.18; -// TODO: can we declare these outside of contract, just in the ZNSAccessController file? abstract contract ZNSRoles { // the highest rank, assigns Admins, new roles and Role Admins bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE"); // the main maintainer role, that gets access to all system functions bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); - // operator can be here to future proof, if we need a new role + // executor can be here to future proof, if we need a new role // so we don't have to upgrade all contracts - // TODO AC: possibly remove executor role? bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE"); // this role is here specifically for the ZNSRegistrar contract bytes32 public constant REGISTRAR_ROLE = keccak256("REGISTRAR_ROLE"); diff --git a/contracts/distribution/ZNSRegistrar.sol b/contracts/distribution/ZNSRegistrar.sol index 3faa13452..d87fb9986 100644 --- a/contracts/distribution/ZNSRegistrar.sol +++ b/contracts/distribution/ZNSRegistrar.sol @@ -93,9 +93,6 @@ contract ZNSRegistrar is AccessControlled, UUPSUpgradeable, IZNSRegistrar { return domainHash; } - // TODO: figure out how to guard this so people can stake tokens - // without the risk of staking contract or wallet to call reclaim+revoke - // from underneath them function revokeDomain(bytes32 domainHash) external override diff --git a/contracts/registry/ZNSRegistry.sol b/contracts/registry/ZNSRegistry.sol index b5e81a87b..27ee4a17d 100644 --- a/contracts/registry/ZNSRegistry.sol +++ b/contracts/registry/ZNSRegistry.sol @@ -26,7 +26,6 @@ contract ZNSRegistry is AccessControlled, UUPSUpgradeable, IZNSRegistry { * @param domainHash the hash of a domain's name */ modifier onlyOwnerOrOperator(bytes32 domainHash) { - // TODO: consider using errors instead of requires with string msgs require( isOwnerOrOperator(domainHash, msg.sender), "ZNSRegistry: Not authorized" diff --git a/src/deploy.ts b/src/deploy.ts deleted file mode 100644 index 1dbf684da..000000000 --- a/src/deploy.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as hre from "hardhat"; -import { ZNSRegistry, ZNSRegistry__factory } from "../typechain"; - -// eslint-disable-next-line prefer-arrow/prefer-arrow-functions -async function main () { - const [deployer] = await hre.ethers.getSigners(); - - const factory = new ZNSRegistry__factory(deployer); - const registry : ZNSRegistry = await factory.deploy(); - - await registry.deployed(); -} - -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. -main().catch(error => { - // eslint-disable-next-line no-console - console.error(error); - process.exitCode = 1; -}); diff --git a/test/ZNSRegistry.test.ts b/test/ZNSRegistry.test.ts index 119118a33..b32ae7016 100644 --- a/test/ZNSRegistry.test.ts +++ b/test/ZNSRegistry.test.ts @@ -376,7 +376,6 @@ describe("ZNSRegistry", () => { describe("Event emitters", () => { it("Emits an event when an operator is set", async () => { - // TODO currently no AC on this function, make sure it's added const tx = zns.registry.connect(deployer).setOwnerOperator(randomUser.address, true); await expect(tx).to.emit(zns.registry, "OperatorPermissionSet").withArgs( diff --git a/test/helpers/types.ts b/test/helpers/types.ts index 45675fd6d..fece0d9e5 100644 --- a/test/helpers/types.ts +++ b/test/helpers/types.ts @@ -6,7 +6,6 @@ import { ZNSPriceOracle, ZNSRegistry, ZNSTreasury, - ZeroTokenMock, ZNSAccessController, ZNSRegistrarUpgradeMock, ZNSPriceOracleUpgradeMock, @@ -19,7 +18,7 @@ import { ZNSRegistrarUpgradeMock__factory, ZNSPriceOracleUpgradeMock__factory, ZNSRegistryUpgradeMock__factory, - ZNSTreasuryUpgradeMock__factory, + ZNSTreasuryUpgradeMock__factory, ZeroToken, } from "../../typechain"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; @@ -74,7 +73,7 @@ export interface ZNSContracts { accessController : ZNSAccessController; registry : ZNSRegistry; domainToken : ZNSDomainToken; - zeroToken : ZeroTokenMock; // TODO fix when real token + zeroToken : ZeroToken; addressResolver : ZNSAddressResolver; priceOracle : ZNSPriceOracle; treasury : ZNSTreasury; From 8d39b27bd37a8cca4d94d4a2a4201a7a480aa674 Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 15 Jun 2023 15:29:06 -0700 Subject: [PATCH 02/16] add reference hashes to test that namehash lib hashes the same as our contracts --- test/ZNSEthRegistrar.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/ZNSEthRegistrar.test.ts b/test/ZNSEthRegistrar.test.ts index 1626b7c7f..55f9dad35 100644 --- a/test/ZNSEthRegistrar.test.ts +++ b/test/ZNSEthRegistrar.test.ts @@ -135,7 +135,10 @@ describe("ZNSRegistrar", () => { zns, defaultDomain ); + + const namehashRef = hashDomainName(defaultDomain); const domainHash = await getDomainHashFromEvent(tx); + expect(domainHash).to.eq(namehashRef); const { owner: ownerFromReg, @@ -153,14 +156,15 @@ describe("ZNSRegistrar", () => { await expect(tx).to.be.revertedWith("ERC20: transfer amount exceeds balance"); }); - // TODO this needs to be checked also with ENS namehash lib - // to make sure that hashing process allows for these characters as well it("Allows unicode characters in domain names", async () => { const unicodeDomain = "œ柸þ€§ᆰ"; + const namehashRef = hashDomainName(unicodeDomain); const tx = await defaultRegistration(user, zns, unicodeDomain); const domainHash = await getDomainHashFromEvent(tx); + // validate that namehash lib works the same way as our contract hashing + expect(domainHash).to.eq(namehashRef); expect(await zns.registry.exists(domainHash)).to.be.true; const expectedStaked = await getPrice(unicodeDomain, zns.priceOracle, true); From 7225e67618af9e38f78f98b2fe728196ab7e80a7 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 10:14:31 -0700 Subject: [PATCH 03/16] change all transfers to safeTransfers --- contracts/distribution/ZNSTreasury.sol | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/contracts/distribution/ZNSTreasury.sol b/contracts/distribution/ZNSTreasury.sol index cb13325ca..1ce365a65 100644 --- a/contracts/distribution/ZNSTreasury.sol +++ b/contracts/distribution/ZNSTreasury.sol @@ -6,9 +6,12 @@ import { IZNSPriceOracle } from "./IZNSPriceOracle.sol"; import { AccessControlled } from "../access/AccessControlled.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract ZNSTreasury is AccessControlled, UUPSUpgradeable, IZNSTreasury { + using SafeERC20 for IERC20; + /** * @notice The price oracle */ @@ -17,12 +20,6 @@ contract ZNSTreasury is AccessControlled, UUPSUpgradeable, IZNSTreasury { /** * @notice The payment/staking token */ - // TODO: this should be changed to be more general - // we might not use ZERO, but any other token here - // so change the naming and change the interface for IERC20, - // instead of a specific ZERO token interface! - // Make sure it is general on all contracts where it's present! - // TODO: change all transfer calls to safeTransfer! IERC20 public stakingToken; /** @@ -62,10 +59,8 @@ contract ZNSTreasury is AccessControlled, UUPSUpgradeable, IZNSTreasury { ); // Transfer stake amount and fee - stakingToken.transferFrom(depositor, address(this), stakeAmount); - // TODO make sure we show the approval process to the user here to avoid failed transfer - // TODO can we make it so it needs a single approval only?! - stakingToken.transferFrom(depositor, zeroVault, registrationFee); + stakingToken.safeTransferFrom(depositor, address(this), stakeAmount + registrationFee); + stakingToken.safeTransfer(zeroVault, registrationFee); // Record staked amount for this domain stakedForDomain[domainHash] = stakeAmount; @@ -81,7 +76,7 @@ contract ZNSTreasury is AccessControlled, UUPSUpgradeable, IZNSTreasury { require(stakeAmount > 0, "ZNSTreasury: No stake for domain"); delete stakedForDomain[domainHash]; - stakingToken.transfer(owner, stakeAmount); + stakingToken.safeTransfer(owner, stakeAmount); emit StakeWithdrawn(domainHash, owner, stakeAmount); } From 8d580e14e649cb891330364642577688f0c42d73 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 10:14:55 -0700 Subject: [PATCH 04/16] add fee checks for staking --- test/ZNSTreasury.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/ZNSTreasury.test.ts b/test/ZNSTreasury.test.ts index 747748c03..d8dc4320d 100644 --- a/test/ZNSTreasury.test.ts +++ b/test/ZNSTreasury.test.ts @@ -65,6 +65,7 @@ describe("ZNSTreasury", () => { const domainHash = hashDomainLabel(domain); const balanceBeforeStake = await zns.zeroToken.balanceOf(user.address); + const zeroVaultBalanceBeforeStake = await zns.zeroToken.balanceOf(zeroVault.address); await zns.treasury.connect(mockRegistrar).stakeForDomain( domainHash, @@ -84,6 +85,9 @@ describe("ZNSTreasury", () => { target: stake.add(fee), shouldDecrease: true, }); + + const zeroVaultBalanceAfterStake = await zns.zeroToken.balanceOf(zeroVault.address); + expect(zeroVaultBalanceAfterStake).to.eq(zeroVaultBalanceBeforeStake.add(fee)); }); it("Should revert if called from an address without REGISTRAR_ROLE", async () => { From 538835a83660774710b605af74fb8eef61f84250 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 12:15:15 -0700 Subject: [PATCH 05/16] expand stakeDeposited event, refactor stake for domain to only require one approval, get totalPrice from oracle --- contracts/access/ZNSAccessController.sol | 1 - contracts/distribution/ZNSTreasury.sol | 16 +++++++++++++--- contracts/registry/ZNSRegistry.sol | 12 ++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/contracts/access/ZNSAccessController.sol b/contracts/access/ZNSAccessController.sol index 0975ccd09..ce30c5df6 100644 --- a/contracts/access/ZNSAccessController.sol +++ b/contracts/access/ZNSAccessController.sol @@ -25,7 +25,6 @@ contract ZNSAccessController is AccessControlUpgradeable, ZNSRoles, IZNSAccessCo } // ** Access Validators ** - function checkGovernor(address account) external view override { _checkRole(GOVERNOR_ROLE, account); } diff --git a/contracts/distribution/ZNSTreasury.sol b/contracts/distribution/ZNSTreasury.sol index 1ce365a65..4e9579ab8 100644 --- a/contracts/distribution/ZNSTreasury.sol +++ b/contracts/distribution/ZNSTreasury.sol @@ -53,19 +53,29 @@ contract ZNSTreasury is AccessControlled, UUPSUpgradeable, IZNSTreasury { bool isTopLevelDomain ) external override onlyRegistrar { // Get price and fee for the domain - (, uint256 stakeAmount, uint256 registrationFee) = priceOracle.getPrice( + ( + uint256 totalPrice, + uint256 stakeAmount, + uint256 registrationFee + ) = priceOracle.getPrice( domainName, isTopLevelDomain ); // Transfer stake amount and fee - stakingToken.safeTransferFrom(depositor, address(this), stakeAmount + registrationFee); + stakingToken.safeTransferFrom(depositor, address(this), totalPrice); stakingToken.safeTransfer(zeroVault, registrationFee); // Record staked amount for this domain stakedForDomain[domainHash] = stakeAmount; - emit StakeDeposited(domainHash, domainName, depositor, stakeAmount); + emit StakeDeposited( + domainHash, + domainName, + depositor, + stakeAmount, + registrationFee + ); } function unstakeForDomain( diff --git a/contracts/registry/ZNSRegistry.sol b/contracts/registry/ZNSRegistry.sol index 27ee4a17d..3a1d9abfe 100644 --- a/contracts/registry/ZNSRegistry.sol +++ b/contracts/registry/ZNSRegistry.sol @@ -33,11 +33,6 @@ contract ZNSRegistry is AccessControlled, UUPSUpgradeable, IZNSRegistry { _; } - modifier onlyRegistrar { - accessController.checkRegistrar(msg.sender); - _; - } - modifier onlyOwner(bytes32 domainHash) { require( records[domainHash].owner == msg.sender, @@ -46,6 +41,11 @@ contract ZNSRegistry is AccessControlled, UUPSUpgradeable, IZNSRegistry { _; } + modifier onlyRegistrar { + accessController.checkRegistrar(msg.sender); + _; + } + /** * @notice Initialize the ZNSRegistry contract * @param accessController The address of the AccessController contract @@ -137,7 +137,7 @@ contract ZNSRegistry is AccessControlled, UUPSUpgradeable, IZNSRegistry { } /** - * @notice Update an existing domain record's owner or resolver + * @notice Update an existing domain record's owner and resolver * @param domainHash The hash of the domain * @param owner The owner or an allowed operator of that domain * @param resolver The resolver for the domain From def80cd2733d3aa0d1882c3afdd7b8bfa6484785 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 12:15:35 -0700 Subject: [PATCH 06/16] update interface --- contracts/distribution/IZNSTreasury.sol | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/distribution/IZNSTreasury.sol b/contracts/distribution/IZNSTreasury.sol index 1765eaa26..2cfd25f8a 100644 --- a/contracts/distribution/IZNSTreasury.sol +++ b/contracts/distribution/IZNSTreasury.sol @@ -8,25 +8,26 @@ interface IZNSTreasury { * @param domainHash The hash of the domain name * @param domainName The domain name * @param depositor The address of the depositing user - * @param amount The amount they are depositing + * @param stakeAmount The amount they are depositing */ event StakeDeposited( bytes32 indexed domainHash, string domainName, address indexed depositor, - uint256 indexed amount + uint256 indexed stakeAmount, + uint256 registrationFee ); /** * @notice Emitted when a stake is withdrawn * @param domainHash The hash of the domain name * @param owner The owner of the domain - * @param amount The amount withdrawn + * @param stakeAmount The staked amount withdrawn */ event StakeWithdrawn( bytes32 indexed domainHash, address indexed owner, - uint256 indexed amount + uint256 indexed stakeAmount ); event PriceOracleSet(address priceOracle); From 6b33f25c9afd65bd1a7dc4cc118235125ffa0a0d Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 12:15:58 -0700 Subject: [PATCH 07/16] expand registrar event, change name from resolverContent to domainAddress --- contracts/distribution/IZNSRegistrar.sol | 3 ++- contracts/distribution/ZNSRegistrar.sol | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/contracts/distribution/IZNSRegistrar.sol b/contracts/distribution/IZNSRegistrar.sol index 29ae9f259..d4949ac10 100644 --- a/contracts/distribution/IZNSRegistrar.sol +++ b/contracts/distribution/IZNSRegistrar.sol @@ -8,7 +8,8 @@ interface IZNSRegistrar { uint256 indexed tokenId, string name, address indexed registrant, - address resolver + address resolver, + address domainAddress ); event DomainRevoked(bytes32 indexed domainHash, address indexed registrant); diff --git a/contracts/distribution/ZNSRegistrar.sol b/contracts/distribution/ZNSRegistrar.sol index d87fb9986..5ce7d05d7 100644 --- a/contracts/distribution/ZNSRegistrar.sol +++ b/contracts/distribution/ZNSRegistrar.sol @@ -58,7 +58,7 @@ contract ZNSRegistrar is AccessControlled, UUPSUpgradeable, IZNSRegistrar { */ function registerDomain( string calldata name, - address resolverContent + address domainAddress ) external override returns (bytes32) { require( bytes(name).length != 0, @@ -80,14 +80,15 @@ contract ZNSRegistrar is AccessControlled, UUPSUpgradeable, IZNSRegistrar { uint256 tokenId = uint256(domainHash); domainToken.register(msg.sender, tokenId); - _setDomainData(domainHash, msg.sender, resolverContent); + _setDomainData(domainHash, msg.sender, domainAddress); emit DomainRegistered( domainHash, tokenId, name, msg.sender, - address(addressResolver) + address(addressResolver), + domainAddress ); return domainHash; @@ -101,8 +102,8 @@ contract ZNSRegistrar is AccessControlled, UUPSUpgradeable, IZNSRegistrar { { uint256 tokenId = uint256(domainHash); domainToken.revoke(tokenId); - treasury.unstakeForDomain(domainHash, msg.sender); registry.deleteRecord(domainHash); + treasury.unstakeForDomain(domainHash, msg.sender); emit DomainRevoked(domainHash, msg.sender); } @@ -174,17 +175,17 @@ contract ZNSRegistrar is AccessControlled, UUPSUpgradeable, IZNSRegistrar { * * @param domainHash The domain name hash * @param owner The owner of that domain - * @param resolverContent The content it resolves to + * @param domainAddress The content it resolves to */ function _setDomainData( bytes32 domainHash, address owner, - address resolverContent + address domainAddress ) internal { // Set only the domain owner if no resolver content is given - if (resolverContent != address(0)) { + if (domainAddress != address(0)) { registry.createDomainRecord(domainHash, owner, address(addressResolver)); - addressResolver.setAddress(domainHash, resolverContent); + addressResolver.setAddress(domainHash, domainAddress); } else { registry.createDomainRecord(domainHash, owner, address(0)); } From 4dfd852456a8f3cb00bcac842f9c37eb21ddae0f Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 12:16:13 -0700 Subject: [PATCH 08/16] add event test for treasury --- test/ZNSPriceOracle.test.ts | 2 -- test/ZNSTreasury.test.ts | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/test/ZNSPriceOracle.test.ts b/test/ZNSPriceOracle.test.ts index da00a6024..a902f050e 100644 --- a/test/ZNSPriceOracle.test.ts +++ b/test/ZNSPriceOracle.test.ts @@ -35,8 +35,6 @@ describe("ZNSPriceOracle", () => { }); }); - // TODO reg: add tests for proper fee calcs! - it("Confirms values were initially set correctly", async () => { const valueCalls = [ zns.priceOracle.feePercentage(), diff --git a/test/ZNSTreasury.test.ts b/test/ZNSTreasury.test.ts index d8dc4320d..480c31a6e 100644 --- a/test/ZNSTreasury.test.ts +++ b/test/ZNSTreasury.test.ts @@ -1,7 +1,7 @@ import * as hre from "hardhat"; import { expect } from "chai"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; -import { checkBalance, deployZNS, validateUpgrade } from "./helpers"; +import { checkBalance, deployZNS, getPriceObject, validateUpgrade } from "./helpers"; import { DeployZNSParams, ZNSContracts } from "./helpers/types"; import * as ethers from "ethers"; import { hashDomainLabel, hashDomainName } from "./helpers/hashing"; @@ -105,6 +105,37 @@ describe("ZNSTreasury", () => { getAccessRevertMsg(randomAcc.address, REGISTRAR_ROLE) ); }); + + it("Should fire StakeDeposited event with correct params", async () => { + const domain = "wilder"; + const domainHash = hashDomainLabel(domain); + + const { + expectedPrice, + fee, + } = await getPriceObject( + domain, + zns.priceOracle, + true, + ); + + const tx = zns.treasury.connect(mockRegistrar).stakeForDomain( + domainHash, + domain, + user.address, + true + ); + + await expect(tx) + .to.emit(zns.treasury, "StakeDeposited") + .withArgs( + domainHash, + domain, + user.address, + expectedPrice, + fee + ); + }); }); describe("#unstakeForDomain", () => { From 4d09348ae48a5f2d187ec0cd1f699488be9c3584 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 12:23:07 -0700 Subject: [PATCH 09/16] add underscore to all params that shadows state var naming --- contracts/distribution/ZNSPriceOracle.sol | 2 +- contracts/distribution/ZNSTreasury.sol | 8 ++++---- contracts/registry/ZNSRegistry.sol | 4 ++-- contracts/resolver/ZNSAddressResolver.sol | 12 ++++++------ contracts/token/ZNSDomainToken.sol | 12 ++++++------ 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/contracts/distribution/ZNSPriceOracle.sol b/contracts/distribution/ZNSPriceOracle.sol index 812c7dab8..d2c7ef79b 100644 --- a/contracts/distribution/ZNSPriceOracle.sol +++ b/contracts/distribution/ZNSPriceOracle.sol @@ -171,7 +171,7 @@ contract ZNSPriceOracle is AccessControlled, UUPSUpgradeable, IZNSPriceOracle { emit BaseLengthsSet(rootLength, subdomainLength); } - function setAccessController(address accessController) + function setAccessController(address accessController_) external override(AccessControlled, IZNSPriceOracle) onlyAdmin diff --git a/contracts/distribution/ZNSTreasury.sol b/contracts/distribution/ZNSTreasury.sol index 4e9579ab8..3c28f030b 100644 --- a/contracts/distribution/ZNSTreasury.sol +++ b/contracts/distribution/ZNSTreasury.sol @@ -91,11 +91,11 @@ contract ZNSTreasury is AccessControlled, UUPSUpgradeable, IZNSTreasury { emit StakeWithdrawn(domainHash, owner, stakeAmount); } - function setZeroVaultAddress(address zeroVaultAddress) public override onlyAdmin { - require(zeroVaultAddress != address(0), "ZNSTreasury: zeroVault passed as 0x0 address"); + function setZeroVaultAddress(address zeroVault_) public override onlyAdmin { + require(zeroVault_ != address(0), "ZNSTreasury: zeroVault passed as 0x0 address"); - zeroVault = zeroVaultAddress; - emit ZeroVaultAddressSet(zeroVaultAddress); + zeroVault = zeroVault_; + emit ZeroVaultAddressSet(zeroVault_); } function setPriceOracle(address priceOracle_) public override onlyAdmin { diff --git a/contracts/registry/ZNSRegistry.sol b/contracts/registry/ZNSRegistry.sol index 3a1d9abfe..891b660dd 100644 --- a/contracts/registry/ZNSRegistry.sol +++ b/contracts/registry/ZNSRegistry.sol @@ -50,8 +50,8 @@ contract ZNSRegistry is AccessControlled, UUPSUpgradeable, IZNSRegistry { * @notice Initialize the ZNSRegistry contract * @param accessController The address of the AccessController contract */ - function initialize(address accessController) public override initializer { - _setAccessController(accessController); + function initialize(address accessController_) public override initializer { + _setAccessController(accessController_); } /** diff --git a/contracts/resolver/ZNSAddressResolver.sol b/contracts/resolver/ZNSAddressResolver.sol index 170906384..36c04488c 100644 --- a/contracts/resolver/ZNSAddressResolver.sol +++ b/contracts/resolver/ZNSAddressResolver.sol @@ -20,16 +20,16 @@ contract ZNSAddressResolver is AccessControlled, UUPSUpgradeable, ERC165, IZNSAd * to Ethereum wallets or contracts registered in ZNS */ mapping(bytes32 domainHash => address resolvedAddress) - private addressOf; + private domainAddresses; /** * @notice Initialize an instance of the ZNSAddressResolver * @param _accessController The access controller * @param _registry The registry address */ - function initialize(address _accessController, address _registry) public override initializer { - _setAccessController(_accessController); - setRegistry(_registry); + function initialize(address accessController_, address registry_) public override initializer { + _setAccessController(accessController_); + setRegistry(registry_); } /** @@ -39,7 +39,7 @@ contract ZNSAddressResolver is AccessControlled, UUPSUpgradeable, ERC165, IZNSAd function getAddress( bytes32 domainHash ) external view override returns (address) { - return addressOf[domainHash]; + return domainAddresses[domainHash]; } /** @@ -59,7 +59,7 @@ contract ZNSAddressResolver is AccessControlled, UUPSUpgradeable, ERC165, IZNSAd "ZNSAddressResolver: Not authorized for this domain" ); - addressOf[domainHash] = newAddress; + domainAddresses[domainHash] = newAddress; emit AddressSet(domainHash, newAddress); } diff --git a/contracts/token/ZNSDomainToken.sol b/contracts/token/ZNSDomainToken.sol index 23fbce9dc..8810c1a61 100644 --- a/contracts/token/ZNSDomainToken.sol +++ b/contracts/token/ZNSDomainToken.sol @@ -17,12 +17,12 @@ contract ZNSDomainToken is AccessControlled, UUPSUpgradeable, ERC721Upgradeable, } function initialize( - address accessController, - string memory tokenName, - string memory tokenSymbol + address accessController_, + string memory name_, + string memory symbol_ ) external override initializer { - __ERC721_init(tokenName, tokenSymbol); - _setAccessController(accessController); + __ERC721_init(name_, symbol_); + _setAccessController(accessController_); } /** @@ -42,7 +42,7 @@ contract ZNSDomainToken is AccessControlled, UUPSUpgradeable, ERC721Upgradeable, _burn(tokenId); } - function setAccessController(address accessController) + function setAccessController(address accessController_) external override(AccessControlled, IZNSDomainToken) onlyAdmin From c4431b09bf362642354eeb8173b7169cf296a7b7 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 16 Jun 2023 15:19:33 -0700 Subject: [PATCH 10/16] fix naming issues --- contracts/distribution/ZNSPriceOracle.sol | 2 +- contracts/distribution/ZNSRegistrar.sol | 2 +- contracts/registry/IZNSRegistry.sol | 2 +- contracts/registry/ZNSRegistry.sol | 2 +- contracts/resolver/ZNSAddressResolver.sol | 6 +++--- contracts/token/ZNSDomainToken.sol | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/distribution/ZNSPriceOracle.sol b/contracts/distribution/ZNSPriceOracle.sol index d2c7ef79b..28725c877 100644 --- a/contracts/distribution/ZNSPriceOracle.sol +++ b/contracts/distribution/ZNSPriceOracle.sol @@ -176,7 +176,7 @@ contract ZNSPriceOracle is AccessControlled, UUPSUpgradeable, IZNSPriceOracle { override(AccessControlled, IZNSPriceOracle) onlyAdmin { - _setAccessController(accessController); + _setAccessController(accessController_); } function getAccessController() external view override(AccessControlled, IZNSPriceOracle) returns (address) { diff --git a/contracts/distribution/ZNSRegistrar.sol b/contracts/distribution/ZNSRegistrar.sol index 5ce7d05d7..45e678511 100644 --- a/contracts/distribution/ZNSRegistrar.sol +++ b/contracts/distribution/ZNSRegistrar.sol @@ -54,7 +54,7 @@ contract ZNSRegistrar is AccessControlled, UUPSUpgradeable, IZNSRegistrar { * @notice Register a new domain such as `0://wilder` * * @param name Name of the domain to register - * @param resolverContent Address for the resolver to return when requested (optional, send 0x0 if not needed) + * @param domainAddress Address for the resolver to return when requested (optional, send 0x0 if not needed) */ function registerDomain( string calldata name, diff --git a/contracts/registry/IZNSRegistry.sol b/contracts/registry/IZNSRegistry.sol index 488678307..9a9b0fcf5 100644 --- a/contracts/registry/IZNSRegistry.sol +++ b/contracts/registry/IZNSRegistry.sol @@ -163,5 +163,5 @@ interface IZNSRegistry { /** * @notice Get the access controller contract */ - function getAccessController() view external returns(address); + function getAccessController() external view returns(address); } diff --git a/contracts/registry/ZNSRegistry.sol b/contracts/registry/ZNSRegistry.sol index 891b660dd..a424a3e87 100644 --- a/contracts/registry/ZNSRegistry.sol +++ b/contracts/registry/ZNSRegistry.sol @@ -48,7 +48,7 @@ contract ZNSRegistry is AccessControlled, UUPSUpgradeable, IZNSRegistry { /** * @notice Initialize the ZNSRegistry contract - * @param accessController The address of the AccessController contract + * @param accessController_ The address of the AccessController contract */ function initialize(address accessController_) public override initializer { _setAccessController(accessController_); diff --git a/contracts/resolver/ZNSAddressResolver.sol b/contracts/resolver/ZNSAddressResolver.sol index 36c04488c..be4fa7e31 100644 --- a/contracts/resolver/ZNSAddressResolver.sol +++ b/contracts/resolver/ZNSAddressResolver.sol @@ -24,8 +24,8 @@ contract ZNSAddressResolver is AccessControlled, UUPSUpgradeable, ERC165, IZNSAd /** * @notice Initialize an instance of the ZNSAddressResolver - * @param _accessController The access controller - * @param _registry The registry address + * @param accessController_ The access controller + * @param registry_ The registry address */ function initialize(address accessController_, address registry_) public override initializer { _setAccessController(accessController_); @@ -108,7 +108,7 @@ contract ZNSAddressResolver is AccessControlled, UUPSUpgradeable, ERC165, IZNSAd * @notice To use UUPS proxy we override this function and revert if `msg.sender` isn't authorized * @param newImplementation The implementation contract to upgrade to */ - // solhint-disable-next-line + // solhint-disable-next-line unused-vars function _authorizeUpgrade(address newImplementation) internal view override { accessController.checkGovernor(msg.sender); } diff --git a/contracts/token/ZNSDomainToken.sol b/contracts/token/ZNSDomainToken.sol index 8810c1a61..d778c2f75 100644 --- a/contracts/token/ZNSDomainToken.sol +++ b/contracts/token/ZNSDomainToken.sol @@ -47,7 +47,7 @@ contract ZNSDomainToken is AccessControlled, UUPSUpgradeable, ERC721Upgradeable, override(AccessControlled, IZNSDomainToken) onlyAdmin { - _setAccessController(accessController); + _setAccessController(accessController_); } function getAccessController() external view override(AccessControlled, IZNSDomainToken) returns (address) { From 8fa85a4ddd338ae2c05cee5b5543b9ce26ce118f Mon Sep 17 00:00:00 2001 From: Kirill Date: Tue, 20 Jun 2023 11:37:47 -0700 Subject: [PATCH 11/16] fix calls to ens namehash in tests --- test/ZNSAddressResolver.test.ts | 4 ++-- test/ZNSEthRegistrar.test.ts | 14 +++++++++----- test/ZNSRegistry.test.ts | 8 ++++---- test/ZNSTreasury.test.ts | 4 ++-- test/helpers/hashing.ts | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/test/ZNSAddressResolver.test.ts b/test/ZNSAddressResolver.test.ts index 37d144ebc..a3a990012 100644 --- a/test/ZNSAddressResolver.test.ts +++ b/test/ZNSAddressResolver.test.ts @@ -2,7 +2,7 @@ import * as hre from "hardhat"; import { ERC165__factory, ZNSAddressResolverUpgradeMock__factory } from "../typechain"; import { DeployZNSParams, ZNSContracts } from "./helpers/types"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; -import { hashDomainLabel, hashDomainName } from "./helpers/hashing"; +import { hashDomainLabel, hashSubdomainName } from "./helpers/hashing"; import { ADMIN_ROLE, GOVERNOR_ROLE, @@ -40,7 +40,7 @@ describe("ZNSAddressResolver", () => { zns = await deployZNS(params); // Have to get this value for every test, but can be fixed - wilderDomainHash = hashDomainName("wilder"); + wilderDomainHash = hashSubdomainName("wilder"); await zns.accessController.connect(deployer).grantRole(REGISTRAR_ROLE, mockRegistrar.address); diff --git a/test/ZNSEthRegistrar.test.ts b/test/ZNSEthRegistrar.test.ts index 55f9dad35..05381a6c4 100644 --- a/test/ZNSEthRegistrar.test.ts +++ b/test/ZNSEthRegistrar.test.ts @@ -2,7 +2,9 @@ import * as hre from "hardhat"; import { expect } from "chai"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { - deployZNS, hashDomainName, INVALID_TOKENID_ERC_ERR, + deployZNS, + hashDomainLabel, + INVALID_TOKENID_ERC_ERR, NOT_AUTHORIZED_REG_ERR, NOT_NAME_OWNER_RAR_ERR, NOT_TOKEN_OWNER_RAR_ERR, ONLY_NAME_OWNER_REG_ERR, @@ -136,7 +138,7 @@ describe("ZNSRegistrar", () => { defaultDomain ); - const namehashRef = hashDomainName(defaultDomain); + const namehashRef = hashDomainLabel(defaultDomain); const domainHash = await getDomainHashFromEvent(tx); expect(domainHash).to.eq(namehashRef); @@ -158,13 +160,15 @@ describe("ZNSRegistrar", () => { it("Allows unicode characters in domain names", async () => { const unicodeDomain = "œ柸þ€§ᆰ"; - const namehashRef = hashDomainName(unicodeDomain); const tx = await defaultRegistration(user, zns, unicodeDomain); const domainHash = await getDomainHashFromEvent(tx); // validate that namehash lib works the same way as our contract hashing - expect(domainHash).to.eq(namehashRef); + // TODO: figure out why these do not match! For some reason contract returns + // a different domain from ensjs. + // const namehashRef = hashDomainLabel(unicodeDomain); + // expect(domainHash).to.eq(namehashRef); expect(await zns.registry.exists(domainHash)).to.be.true; const expectedStaked = await getPrice(unicodeDomain, zns.priceOracle, true); @@ -666,7 +670,7 @@ describe("ZNSRegistrar", () => { await registrar.deployed(); const domainName = "world"; - const domainHash = hashDomainName(domainName); + const domainHash = hashDomainLabel(domainName); await zns.registrar.registerDomain(domainName, randomUser.address); diff --git a/test/ZNSRegistry.test.ts b/test/ZNSRegistry.test.ts index b32ae7016..3dbfa2f96 100644 --- a/test/ZNSRegistry.test.ts +++ b/test/ZNSRegistry.test.ts @@ -2,7 +2,7 @@ import * as hre from "hardhat"; import { expect } from "chai"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { deployZNS } from "./helpers/deployZNS"; -import { hashDomainLabel, hashDomainName } from "./helpers/hashing"; +import { hashDomainLabel, hashSubdomainName } from "./helpers/hashing"; import { ZNSContracts, DeployZNSParams } from "./helpers/types"; import { ZNSRegistryUpgradeMock__factory } from "../typechain"; import { ethers } from "ethers"; @@ -47,7 +47,7 @@ describe("ZNSRegistry", () => { zns = await deployZNS(params); - wilderDomainHash = hashDomainName("wilder"); + wilderDomainHash = hashSubdomainName("wilder"); await zns.accessController.connect(deployer).grantRole(REGISTRAR_ROLE, mockRegistrar.address); @@ -140,7 +140,7 @@ describe("ZNSRegistry", () => { const exists = await zns.registry.connect(randomUser).exists(wilderDomainHash); expect(exists).to.be.true; - const nonExistentDomainHash = hashDomainName("wild"); + const nonExistentDomainHash = hashSubdomainName("wild"); const notExists = await zns.registry.connect(randomUser).exists(nonExistentDomainHash); expect(notExists).to.be.false; @@ -492,7 +492,7 @@ describe("ZNSRegistry", () => { const registry = await registryFactory.deploy(); await registry.deployed(); - const domainHash = hashDomainName("world"); + const domainHash = hashSubdomainName("world"); // Add an operator await zns.registry.connect(deployer).setOwnerOperator(operator.address, true); diff --git a/test/ZNSTreasury.test.ts b/test/ZNSTreasury.test.ts index 480c31a6e..a7ad404b3 100644 --- a/test/ZNSTreasury.test.ts +++ b/test/ZNSTreasury.test.ts @@ -4,7 +4,7 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { checkBalance, deployZNS, getPriceObject, validateUpgrade } from "./helpers"; import { DeployZNSParams, ZNSContracts } from "./helpers/types"; import * as ethers from "ethers"; -import { hashDomainLabel, hashDomainName } from "./helpers/hashing"; +import { hashDomainLabel, hashSubdomainName } from "./helpers/hashing"; import { ADMIN_ROLE, REGISTRAR_ROLE, GOVERNOR_ROLE } from "./helpers/access"; import { getAccessRevertMsg } from "./helpers/errors"; import { ZNSTreasuryUpgradeMock__factory } from "../typechain"; @@ -319,7 +319,7 @@ describe("ZNSTreasury", () => { await expect(zns.accessController.checkGovernor(deployer.address)).to.not.be.reverted; const domainName = "world"; - const domainHash = hashDomainName(domainName); + const domainHash = hashSubdomainName(domainName); await zns.treasury.connect(mockRegistrar).stakeForDomain( domainHash, diff --git a/test/helpers/hashing.ts b/test/helpers/hashing.ts index aa147f17b..2e894dc8f 100644 --- a/test/helpers/hashing.ts +++ b/test/helpers/hashing.ts @@ -16,7 +16,7 @@ export const reverseInputName = (name : string) => { /** * Hashes full domain path. */ -export const hashDomainName = (name : string) => { +export const hashSubdomainName = (name : string) => { // ens namehash lib expects child.parent for hashing algorithm as opposed to our format: parent.child const reversedInputName = reverseInputName(name); const hashedName = ensjs.namehash(reversedInputName); From ce24ff49883b6adf1ba6230798962c4f2f3b4fd3 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 21 Jun 2023 12:28:27 -0700 Subject: [PATCH 12/16] remove redundant imports in oracle --- contracts/distribution/ZNSPriceOracle.sol | 3 --- 1 file changed, 3 deletions(-) diff --git a/contracts/distribution/ZNSPriceOracle.sol b/contracts/distribution/ZNSPriceOracle.sol index 511a0a854..8fd4a4c53 100644 --- a/contracts/distribution/ZNSPriceOracle.sol +++ b/contracts/distribution/ZNSPriceOracle.sol @@ -1,9 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -// TODO polish: check where this is used -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import { IZNSPriceOracle } from "./IZNSPriceOracle.sol"; import { StringUtils } from "../utils/StringUtils.sol"; From 8d0694171e3cc74d42b93acae17ec332b5c7029d Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 21 Jun 2023 12:29:44 -0700 Subject: [PATCH 13/16] add space --- contracts/token/ZNSDomainToken.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/token/ZNSDomainToken.sol b/contracts/token/ZNSDomainToken.sol index d778c2f75..ddfd257e7 100644 --- a/contracts/token/ZNSDomainToken.sol +++ b/contracts/token/ZNSDomainToken.sol @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; + import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import { IZNSDomainToken } from "./IZNSDomainToken.sol"; From 360bc6c8077a61d89a5653496264f847ad97590d Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 21 Jun 2023 13:12:24 -0700 Subject: [PATCH 14/16] fix stakeForDomain call to remove redundant argument --- test/ZNSTreasury.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/ZNSTreasury.test.ts b/test/ZNSTreasury.test.ts index 9d8e74d03..2eb1ebb40 100644 --- a/test/ZNSTreasury.test.ts +++ b/test/ZNSTreasury.test.ts @@ -120,8 +120,7 @@ describe("ZNSTreasury", () => { const tx = zns.treasury.connect(mockRegistrar).stakeForDomain( domainHash, domain, - user.address, - true + user.address ); await expect(tx) From bebea1a78427a2dca71ef64cf344b73960a4b5a6 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 21 Jun 2023 14:12:16 -0700 Subject: [PATCH 15/16] refactor price multiplier setter to not read the whole struct and write that into memory --- contracts/distribution/ZNSPriceOracle.sol | 5 +---- test/ZNSTreasury.test.ts | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/contracts/distribution/ZNSPriceOracle.sol b/contracts/distribution/ZNSPriceOracle.sol index 8fd4a4c53..ec003fff4 100644 --- a/contracts/distribution/ZNSPriceOracle.sol +++ b/contracts/distribution/ZNSPriceOracle.sol @@ -216,15 +216,12 @@ contract ZNSPriceOracle is AccessControlled, UUPSUpgradeable, IZNSPriceOracle { } function _setPriceMultiplier(uint256 multiplier) internal { - // Avoid unnecessary jumps to external storage - DomainPriceConfig memory config = rootDomainPriceConfig; - // The multiplier being 0 will cause a division error in the pricing function require(multiplier > 0, "ZNSPriceOracle: Multiplier cannot be 0"); // The multiplier being larger than the base length will cause spikes in the pricing function require( - multiplier >= config.baseLength + 1, + multiplier >= rootDomainPriceConfig.baseLength + 1, "ZNSPriceOracle: Multiplier must be >= baseLength + 1" ); rootDomainPriceConfig.priceMultiplier = multiplier; diff --git a/test/ZNSTreasury.test.ts b/test/ZNSTreasury.test.ts index 2eb1ebb40..ee6a080de 100644 --- a/test/ZNSTreasury.test.ts +++ b/test/ZNSTreasury.test.ts @@ -113,8 +113,7 @@ describe("ZNSTreasury", () => { fee, } = await getPriceObject( domain, - zns.priceOracle, - true, + zns.priceOracle ); const tx = zns.treasury.connect(mockRegistrar).stakeForDomain( From ba3ea3e49edcb3bb0856142132b99a51232f07e4 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 21 Jun 2023 16:29:09 -0700 Subject: [PATCH 16/16] fix tests and hashing to achieve parity between contracts and ens lib --- test/ZNSRegistrar.test.ts | 23 +++++++++++++---------- test/helpers/hashing.ts | 12 +++++++----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/test/ZNSRegistrar.test.ts b/test/ZNSRegistrar.test.ts index af4950e76..fe5be88f0 100644 --- a/test/ZNSRegistrar.test.ts +++ b/test/ZNSRegistrar.test.ts @@ -4,7 +4,7 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { deployZNS, hashDomainLabel, - INVALID_TOKENID_ERC_ERR, + INVALID_TOKENID_ERC_ERR, normalizeName, NOT_AUTHORIZED_REG_ERR, NOT_NAME_OWNER_RAR_ERR, NOT_TOKEN_OWNER_RAR_ERR, ONLY_NAME_OWNER_REG_ERR, @@ -35,7 +35,7 @@ describe("ZNSRegistrar", () => { let zns : ZNSContracts; let zeroVault : SignerWithAddress; let operator : SignerWithAddress; - const defaultDomain = "wilder"; + const defaultDomain = normalizeName("wilder"); beforeEach(async () => { [deployer, zeroVault, user, operator, governor, admin, randomUser] = await hre.ethers.getSigners(); @@ -158,20 +158,23 @@ describe("ZNSRegistrar", () => { await expect(tx).to.be.revertedWith("ERC20: transfer amount exceeds balance"); }); - it("Allows unicode characters in domain names", async () => { - const unicodeDomain = "œ柸þ€§ᆰ"; + // eslint-disable-next-line max-len + it("Allows unicode characters in domain names and matches the hash of normalized string acquired from namehash library", async () => { + const unicodeDomainLabel = "œ柸þ€§ᆰ"; - const tx = await defaultRegistration(user, zns, unicodeDomain); + const normalizedDomainLabel = normalizeName(unicodeDomainLabel); + + const tx = await defaultRegistration(user, zns, normalizedDomainLabel); const domainHash = await getDomainHashFromEvent(tx); // validate that namehash lib works the same way as our contract hashing - // TODO: figure out why these do not match! For some reason contract returns - // a different domain from ensjs. - // const namehashRef = hashDomainLabel(unicodeDomain); - // expect(domainHash).to.eq(namehashRef); + // TODO: a security issue with namehash lib is the usage of non-ASCII characters + // this should be handled at the SDK/dApp level! + const namehashRef = hashDomainLabel(unicodeDomainLabel); + expect(domainHash).to.eq(namehashRef); expect(await zns.registry.exists(domainHash)).to.be.true; - const expectedStaked = await getPrice(unicodeDomain, zns.priceOracle); + const expectedStaked = await getPrice(normalizedDomainLabel, zns.priceOracle); const staked = await zns.treasury.stakedForDomain(domainHash); expect(expectedStaked).to.eq(staked); }); diff --git a/test/helpers/hashing.ts b/test/helpers/hashing.ts index 2e894dc8f..bdf8b72d3 100644 --- a/test/helpers/hashing.ts +++ b/test/helpers/hashing.ts @@ -1,5 +1,9 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires +/* eslint-disable @typescript-eslint/no-var-requires */ const ensjs = require("@ensdomains/ensjs"); +const namehash = require("eth-ens-namehash"); + + +export const normalizeName = (name : string) => namehash.normalize(name); /** * The ens lib takes the inverse of our domain name format to @@ -19,12 +23,10 @@ export const reverseInputName = (name : string) => { export const hashSubdomainName = (name : string) => { // ens namehash lib expects child.parent for hashing algorithm as opposed to our format: parent.child const reversedInputName = reverseInputName(name); - const hashedName = ensjs.namehash(reversedInputName); - - return hashedName; + return ensjs.namehash(reversedInputName); }; /** * Hashes last name label only. */ -export const hashDomainLabel = (label : string) => ensjs.labelhash(label); \ No newline at end of file +export const hashDomainLabel = (label : string) => ensjs.labelhash(label);