Skip to content

Commit

Permalink
Merge branch 'development' into fix/audit-zns-6
Browse files Browse the repository at this point in the history
  • Loading branch information
Whytecrowe committed Oct 30, 2023
2 parents 1e08edd + a0fe0d7 commit e08ccef
Show file tree
Hide file tree
Showing 42 changed files with 211 additions and 154 deletions.
2 changes: 1 addition & 1 deletion contracts/access/AAccessControlled.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSAccessController } from "./IZNSAccessController.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/access/IZNSAccessController.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/access/ZNSAccessController.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { IZNSAccessController } from "./IZNSAccessController.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/ZNSRoles.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;


/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/oz-proxies/ERC1967ProxyAcc.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

// solhint-disable-next-line no-global-import
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/oz-proxies/TransparentUpgradeableProxyAcc.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

// solhint-disable-next-line no-global-import
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/price/IZNSCurvePricer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ICurvePriceConfig } from "../types/ICurvePriceConfig.sol";
import { IZNSPricer } from "../types/IZNSPricer.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/price/IZNSFixedPricer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSPricer } from "../types/IZNSPricer.sol";

Expand Down
7 changes: 3 additions & 4 deletions contracts/price/ZNSCurvePricer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { IZNSCurvePricer } from "./IZNSCurvePricer.sol";
Expand Down Expand Up @@ -299,8 +299,7 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
if (length <= config.baseLength) return config.maxPrice;
if (length > config.maxLength) return config.minPrice;

return
(config.baseLength * config.maxPrice / length)
return (config.baseLength * config.maxPrice / length)
/ config.precisionMultiplier * config.precisionMultiplier;
}

Expand All @@ -312,7 +311,7 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
* which can occur if some of the config values are not properly chosen and set.
*/
function _validateConfig(bytes32 domainHash) internal view {
uint256 prevToMinPrice = _getPrice(domainHash, priceConfigs[domainHash].maxLength - 1);
uint256 prevToMinPrice = _getPrice(domainHash, priceConfigs[domainHash].maxLength);
require(
priceConfigs[domainHash].minPrice <= prevToMinPrice,
"ZNSCurvePricer: incorrect value set causes the price spike at maxLength."
Expand Down
2 changes: 1 addition & 1 deletion contracts/price/ZNSFixedPricer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { AAccessControlled } from "../access/AAccessControlled.sol";
import { ARegistryWired } from "../registry/ARegistryWired.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/registrar/IZNSRootRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IDistributionConfig } from "../types/IDistributionConfig.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/registrar/IZNSSubRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IDistributionConfig } from "../types/IDistributionConfig.sol";
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/registrar/ZNSRootRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSRootRegistrar, CoreRegisterArgs } from "./IZNSRootRegistrar.sol";
import { IZNSTreasury } from "../treasury/IZNSTreasury.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/registrar/ZNSSubRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSPricer } from "../types/IZNSPricer.sol";
import { IZNSRootRegistrar, CoreRegisterArgs } from "./IZNSRootRegistrar.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/registry/ARegistryWired.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSRegistry } from "./IZNSRegistry.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/registry/ZNSRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSRegistry } from "./IZNSRegistry.sol";
import { AAccessControlled } from "../access/AAccessControlled.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/resolver/IZNSAddressResolver.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;


interface IZNSAddressResolver {
Expand Down
2 changes: 1 addition & 1 deletion contracts/resolver/ZNSAddressResolver.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/IZNSDomainToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import { IERC2981Upgradeable } from "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ZNSDomainToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
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";
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/mocks/CustomDecimalTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

// solhint-disable
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/mocks/IZeroTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/token/mocks/ZeroTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

// solhint-disable
import { ZeroToken } from "@zero-tech/ztoken/contracts/ZeroToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/treasury/IZNSTreasury.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/treasury/ZNSTreasury.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSTreasury } from "./IZNSTreasury.sol";
import { AAccessControlled } from "../access/AAccessControlled.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/types/ICurvePriceConfig.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;


/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/types/IDistributionConfig.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { IZNSPricer } from "../types/IZNSPricer.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/types/IZNSPricer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;


/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgrade-test-mocks/UpgradeMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

/* solhint-disable */
contract UpgradeMock {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ZNSCurvePricer } from "../../price/ZNSCurvePricer.sol";
import { UpgradeMock } from "../UpgradeMock.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ZNSFixedPricer } from "../../price/ZNSFixedPricer.sol";
import { UpgradeMock } from "../UpgradeMock.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ZNSRootRegistrar } from "../../registrar/ZNSRootRegistrar.sol";
import { UpgradeMock } from "../UpgradeMock.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

// solhint-disable
import { ZNSSubRegistrar } from "../../registrar/ZNSSubRegistrar.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ZNSTreasury } from "../../treasury/ZNSTreasury.sol";
import { UpgradeMock } from "../UpgradeMock.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgrade-test-mocks/registry/ZNSRegistryMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ZNSRegistry } from "../../registry/ZNSRegistry.sol";
import { UpgradeMock } from "../UpgradeMock.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ZNSAddressResolver } from "../../resolver/ZNSAddressResolver.sol";
import { UpgradeMock } from "../UpgradeMock.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgrade-test-mocks/token/ZNSDomainTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
pragma solidity 0.8.18;

import { ZNSDomainToken } from "../../token/ZNSDomainToken.sol";
import { UpgradeMock } from "../UpgradeMock.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/StringUtils.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Source:
// https://github.com/ensdomains/ens-contracts/blob/master/contracts/ethregistrar/StringUtils.sol
pragma solidity ^0.8.18;
pragma solidity 0.8.18;


library StringUtils {
Expand Down
42 changes: 42 additions & 0 deletions docs/roles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# zNS Access Roles and Their Privileges

## `GOVERNOR_ROLE` privileges:
- The UUPS function `upgradeToAndCall()` allows governors to update the implementation used and invoke a call in upgradeable
contracts.
- The UUPS function `upgradeTo()` allows governors to update the implementation used in upgradeable contracts.
- The governors can grant `GOVERNOR_ROLE` to addresses.
- The governors can grant `ADMIN_ROLE` to addresses.
- The governors can grant any role to any address through the function `ZNSAccessController.setRoleAdmin()` .

## `ADMIN_ROLE` privileges:
- The function `setRegistry()` allows admins to update the registry address for contracts inheriting `ARegistryWired`:
- `ZNSCurvePricer`
- `ZNSRootRegistrar`
- `ZNSSubRegistrar`
- `ZNSAddressResolver`
- `ZNSDomainToken`
- `ZNSTreasury`
- The function `ZNSRootRegister.setRootPricer()` allows admins to update the pricer contract used to determine pricing for root
domains.
- The function `ZNSRootRegister.setTreasury()` allows admins to update the `ZNSTreasury` contract used to store protocol fees
and staked funds.
- The function `ZNSRootRegister.setDomainToken()` allows admins to update the domain token contract used to validate domain
ownership.
- The function `ZNSRootRegister.setSubRegistrar()` allows admins to update the subdomain registrar contract.
- The function `ZNSRootRegister.setAddressResolver()` allows admins to update the root domain resolver.
- The admins can grant `REGISTRAR_ROLE` to addresses.

## `REGISTRAR_ROLE` privileges:
- The function `ZNSRootRegister.coreRegister()` allows registrars to register domains.
- The function `ZNSRegistry.createDomainRecord()` allows registrars to register domain records which track ownership and address
resolver.
- The function `ZNSDomainToken.register()` allows registrars to mint tokens which are used to validate domain ownership.
- The function `ZNSDomainToken.revoke()` allows registrars to burn tokens to revoke domain ownership.
- The function `ZNSTreasury.stakeForDomain()` allows registrars to process registration fee to beneficiaries and stake domain funds
in the treasury. The staked funds are returned to the domain owner when the domain is revoked.
- The function `ZNSTreasury.unstakeForDomain()` allows registrars to unstake domain registration funds in the treasury during the
domain revocation process.
- The function `ZNSTreasury.processDirectPayment()` allows registrars to process registration fees to beneficiaries directly.
>The `REGISTRAR_ROLE` is reserved for contracts ZNSRootRegistrar and ZNSSubRegistrar only.
>`EXECUTOR_ROLE` does not have any privileges. This role may be used for future implementations and additions.
Loading

0 comments on commit e08ccef

Please sign in to comment.