Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multi ZNS] All code preparations for the new ZNS version on ZChain [INITIAL #1] #110

Open
wants to merge 46 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bd583d5
update solidity version in all contracts
Whytecrowe Jun 21, 2024
e7cad5f
update all the possible packages, including zToken
Whytecrowe Jun 26, 2024
7e127b4
rework meow token deploy logic to use imported artifacts and it's moc…
Whytecrowe Jun 26, 2024
0658ca8
fix inheritance issues in DomainToken
Whytecrowe Jun 26, 2024
8b9a029
fix hardhat config to use proper solc versions
Whytecrowe Jun 26, 2024
7eb8f1a
fix all tests based on the new changes to revert errors and other things
Whytecrowe Jun 26, 2024
40963a7
try newer node image for CI
Whytecrowe Jun 27, 2024
17b764f
try adding more memory to hardhat coverage
Whytecrowe Jun 27, 2024
95bbb0e
try a different way
Whytecrowe Jun 27, 2024
e4f626e
try exporting old space size for Node before running coverage
Whytecrowe Jun 27, 2024
6561363
remove redundant imports
Whytecrowe Jun 27, 2024
70a983c
convert requires to custom errors for Access and Pricers
Whytecrowe Jun 27, 2024
f91e990
make errors for Registry and Registrars
Whytecrowe Jun 27, 2024
b65b7f5
add errors for AddressResolver and Treasury
Whytecrowe Jun 27, 2024
aa73a8b
try rolling back solcover version
Whytecrowe Jun 28, 2024
03f6d7c
update yarn.lock
Whytecrowe Jun 28, 2024
11ea094
fix contract errors to compile
Whytecrowe Jun 28, 2024
c3c9312
fix errors in if statements, add string utils
Whytecrowe Jun 29, 2024
e9dd200
fix error in StringUtils
Whytecrowe Jun 29, 2024
63fd27a
fix error constants in TS
Whytecrowe Jun 29, 2024
de901cf
first pass on reworking test error checks
Whytecrowe Jun 29, 2024
92993cc
second pass on the tests
Whytecrowe Jun 29, 2024
747beb2
try running CI without enlarging the heap
Whytecrowe Jun 29, 2024
0118102
small fixes
Whytecrowe Jun 29, 2024
6d20a06
add missing param to error
Whytecrowe Jun 29, 2024
0506426
Revert "try running CI without enlarging the heap"
Whytecrowe Jun 29, 2024
2aa9f00
try increasing heap to 8gb
Whytecrowe Jul 1, 2024
d1cc7ef
try measureStatementCoverage flag to false for coverage
Whytecrowe Jul 1, 2024
31a1caa
try skipping a large string test
Whytecrowe Jul 1, 2024
7f360bb
try removing the test skip
Whytecrowe Jul 1, 2024
bd7bc84
skip the test back and try removing heap increase
Whytecrowe Jul 1, 2024
be2a980
add missing tests for rootPricer state var
Whytecrowe Jul 2, 2024
cacba86
try adding slip on coverage for a long string name test
Whytecrowe Jul 2, 2024
38f16b0
add NatSpec for some non obvious errors
Whytecrowe Jul 2, 2024
d92590d
add test
Whytecrowe Jul 2, 2024
8789d9d
update hardhat to the newest version
Whytecrowe Jul 2, 2024
6908566
try updating solcover
Whytecrowe Jul 2, 2024
d0e1ae5
Codebase and dependency update (#109)
Whytecrowe Jul 2, 2024
ae74c06
Types upgrade after PROVIDER removal
MichaelKorchagin Jul 16, 2024
b387d4f
Deploy contracts through Hardhat script
MichaelKorchagin Jul 17, 2024
cfd06cc
Add Meow-testnet data
MichaelKorchagin Jul 18, 2024
d3a999f
Disable Meow-testnet
MichaelKorchagin Jul 18, 2024
0db9875
Correct contract format
MichaelKorchagin Jul 18, 2024
449e121
[ZNS ZChain] Update zDC, add deploy scripts for `dev` and ZChain (#113)
Whytecrowe Sep 11, 2024
84f0d12
fix compile (type) errors
Whytecrowe Sep 11, 2024
8513869
add ts compilation to build script so that CI checks for compilation …
Whytecrowe Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ orbs:
defaults: &defaults
working_directory: ~/repo
docker:
- image: cimg/node:18.15.0
- image: cimg/node:18.20.3
- image: mongo:7.0.0-rc5-jammy

jobs:
Expand Down
4 changes: 4 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
mocha: {
grep: "@skip-on-coverage", // Find everything with this tag
invert: true // Run the grep's inverse set.
},
skipFiles: [
'utils/StringUtils.sol',
'token/mocks',
Expand Down
6 changes: 3 additions & 3 deletions contracts/access/AAccessControlled.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
pragma solidity 0.8.26;

import { IZNSAccessController } from "./IZNSAccessController.sol";
import { ZeroAddressPassed } from "../utils/CommonErrors.sol";


/**
Expand All @@ -11,7 +12,6 @@ import { IZNSAccessController } from "./IZNSAccessController.sol";
* this contract needs to be inherited by the module.
*/
abstract contract AAccessControlled {

/**
* @notice Emitted when the access controller contract address is set.
*/
Expand Down Expand Up @@ -66,7 +66,7 @@ abstract contract AAccessControlled {
* @param _accessController Address of the ZNSAccessController contract.
*/
function _setAccessController(address _accessController) internal {
require(_accessController != address(0), "AC: _accessController is 0x0 address");
if (_accessController == address(0)) revert ZeroAddressPassed();
accessController = IZNSAccessController(_accessController);
emit AccessControllerSet(_accessController);
}
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.26;

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

Expand Down
9 changes: 4 additions & 5 deletions contracts/access/ZNSAccessController.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
pragma solidity 0.8.26;

import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { IZNSAccessController } from "./IZNSAccessController.sol";
import { ZNSRoles } from "./ZNSRoles.sol";
import { ZeroAddressPassed } from "../utils/CommonErrors.sol";


/**
Expand Down Expand Up @@ -77,10 +78,8 @@ contract ZNSAccessController is AccessControl, ZNSRoles, IZNSAccessController {
function _grantRoleToMany(bytes32 role, address[] memory addresses) internal {
uint256 length = addresses.length;
for (uint256 i = 0; i < length; ++i) {
require(
addresses[i] != address(0),
"ZNSAccessController: Can't grant role to zero address"
);
if (addresses[i] == address(0)) revert ZeroAddressPassed();

_grantRole(role, addresses[i]);
}
}
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.26;


/**
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.26;

// 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.26;

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

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


interface IZNSCurvePricer is ICurvePriceConfig, IZNSPricer {

/**
* @notice Reverted when multiplier passed by the domain owner
* is equal to 0 or more than 10^18, which is too large.
*/
error InvalidMultiplierPassed(uint256 multiplier);

/**
* @notice Reverted when `priceConfig` set by the owner does not result in a proper asymptotic curve
* and one of it's incorrect values causes the price spike at maxLength, meaning that the price
* for a domain label shorter than `baseLength` (the one before `minPrice`) becomes higher than `minPrice`.
*/
error InvalidConfigCausingPriceSpikes(
bytes32 configsDomainHash,
uint256 minPrice,
uint256 previousToMinPrice
);

/**
* @notice Emitted when the `maxPrice` is set in `CurvePriceConfig`
* @param price The new maxPrice value
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.26;

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

Expand Down
27 changes: 12 additions & 15 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.26;

import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { IZNSCurvePricer } from "./IZNSCurvePricer.sol";
Expand Down Expand Up @@ -75,10 +75,7 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
string calldata label,
bool skipValidityCheck
) public view override returns (uint256) {
require(
priceConfigs[parentHash].isSet,
"ZNSCurvePricer: parent's price config has not been set properly through IZNSPricer.setPriceConfig()"
);
if (!priceConfigs[parentHash].isSet) revert ParentPriceConfigNotSet(parentHash);

if (!skipValidityCheck) {
// Confirms string values are only [a-z0-9-]
Expand Down Expand Up @@ -256,8 +253,8 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
bytes32 domainHash,
uint256 multiplier
) public override onlyOwnerOrOperator(domainHash) {
require(multiplier != 0, "ZNSCurvePricer: precisionMultiplier cannot be 0");
require(multiplier <= 10**18, "ZNSCurvePricer: precisionMultiplier cannot be greater than 10^18");
if (multiplier == 0 || multiplier > 10**18) revert InvalidMultiplierPassed(multiplier);

priceConfigs[domainHash].precisionMultiplier = multiplier;

emit PrecisionMultiplierSet(domainHash, multiplier);
Expand All @@ -275,10 +272,8 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
public
override
onlyOwnerOrOperator(domainHash) {
require(
feePercentage <= PERCENTAGE_BASIS,
"ZNSCurvePricer: feePercentage cannot be greater than PERCENTAGE_BASIS"
);
if (feePercentage > PERCENTAGE_BASIS)
revert FeePercentageValueTooLarge(feePercentage, PERCENTAGE_BASIS);

priceConfigs[domainHash].feePercentage = feePercentage;
emit FeePercentageSet(domainHash, feePercentage);
Expand Down Expand Up @@ -337,10 +332,12 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
*/
function _validateConfig(bytes32 domainHash) internal view {
uint256 prevToMinPrice = _getPrice(domainHash, priceConfigs[domainHash].maxLength);
require(
priceConfigs[domainHash].minPrice <= prevToMinPrice,
"ZNSCurvePricer: incorrect value set causes the price spike at maxLength."
);
if (priceConfigs[domainHash].minPrice > prevToMinPrice)
revert InvalidConfigCausingPriceSpikes(
domainHash,
priceConfigs[domainHash].minPrice,
prevToMinPrice
);
}

/**
Expand Down
13 changes: 4 additions & 9 deletions 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.26;

import { AAccessControlled } from "../access/AAccessControlled.sol";
import { ARegistryWired } from "../registry/ARegistryWired.sol";
Expand Down Expand Up @@ -60,10 +60,7 @@ contract ZNSFixedPricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
string calldata label,
bool skipValidityCheck
) public override view returns (uint256) {
require(
priceConfigs[parentHash].isSet,
"ZNSFixedPricer: parent's price config has not been set properly through IZNSPricer.setPriceConfig()"
);
if (!priceConfigs[parentHash].isSet) revert ParentPriceConfigNotSet(parentHash);

if (!skipValidityCheck) {
// Confirms string values are only [a-z0-9-]
Expand Down Expand Up @@ -161,10 +158,8 @@ contract ZNSFixedPricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
* @param feePercentage The new feePercentage
*/
function _setFeePercentage(bytes32 domainHash, uint256 feePercentage) internal {
require(
feePercentage <= PERCENTAGE_BASIS,
"ZNSFixedPricer: feePercentage cannot be greater than PERCENTAGE_BASIS"
);
if (feePercentage > PERCENTAGE_BASIS)
revert FeePercentageValueTooLarge(feePercentage, PERCENTAGE_BASIS);

priceConfigs[domainHash].feePercentage = feePercentage;
emit FeePercentageSet(domainHash, feePercentage);
Expand Down
10 changes: 8 additions & 2 deletions 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.26;

import { IDistributionConfig } from "../types/IDistributionConfig.sol";
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
Expand Down Expand Up @@ -42,13 +42,19 @@ struct CoreRegisterArgs {
* + `isStakePayment`: A flag for whether the payment is a stake payment or not
*/
interface IZNSRootRegistrar is IDistributionConfig {
error NotTheOwnerOf(
OwnerOf ownerOf,
address candidate,
bytes32 domainHash
);

error InvalidOwnerOfEnumValue(OwnerOf value);

enum OwnerOf {
NAME,
TOKEN,
BOTH
}

/**
* @notice Emitted when a NEW domain is registered.
* @dev `domainAddress` parameter is the address to which a domain name will relate to in ZNS.
Expand Down
44 changes: 29 additions & 15 deletions contracts/registrar/IZNSSubRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
pragma solidity 0.8.26;

import { IDistributionConfig } from "../types/IDistributionConfig.sol";
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
import { IZNSPricer } from "../types/IZNSPricer.sol";


/**
* @title IZNSSubRegistrar.sol - Interface for the ZNSSubRegistrar contract responsible for registering subdomains.
*/
*/
interface IZNSSubRegistrar is IDistributionConfig {
/**
* @notice Reverted when someone other than parent owner is trying to buy
a subdomain under the parent that is locked\
* or when the parent provided does not exist.
*/
error ParentLockedOrDoesntExist(bytes32 parentHash);

/**
* @notice Reverted when the buyer of subdomain is not approved by the parent in it's mintlist.
*/
error SenderNotApprovedForPurchase(bytes32 parentHash, address sender);

/**
* @notice Emitted when a new `DistributionConfig.pricerContract` is set for a domain.
*/
event PricerContractSet(bytes32 indexed domainHash, address indexed pricerContract);
*/
event PricerContractSet(
bytes32 indexed domainHash,
address indexed pricerContract
);

/**
* @notice Emitted when a new `DistributionConfig.paymentType` is set for a domain.
*/
*/
event PaymentTypeSet(bytes32 indexed domainHash, PaymentType paymentType);

/**
* @notice Emitted when a new `DistributionConfig.accessType` is set for a domain.
*/
*/
event AccessTypeSet(bytes32 indexed domainHash, AccessType accessType);

/**
* @notice Emitted when a new full `DistributionConfig` is set for a domain at once.
*/
*/
event DistributionConfigSet(
bytes32 indexed domainHash,
IZNSPricer pricerContract,
Expand All @@ -38,7 +51,7 @@ interface IZNSSubRegistrar is IDistributionConfig {

/**
* @notice Emitted when a `mintlist` is updated for a domain.
*/
*/
event MintlistUpdated(
bytes32 indexed domainHash,
uint256 indexed ownerIndex,
Expand All @@ -54,16 +67,17 @@ interface IZNSSubRegistrar is IDistributionConfig {

/**
* @notice Emitted when the ZNSRootRegistrar address is set in state.
*/
*/
event RootRegistrarSet(address registrar);

function distrConfigs(
bytes32 domainHash
) external view returns (
IZNSPricer pricerContract,
PaymentType paymentType,
AccessType accessType
);
)
external view returns (
IZNSPricer pricerContract,
PaymentType paymentType,
AccessType accessType
);

function isMintlistedForDomain(
bytes32 domainHash,
Expand Down
Loading