Skip to content

Commit d0e1ae5

Browse files
authored
Codebase and dependency update (#109)
2 parents 5dd6a86 + 6908566 commit d0e1ae5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2381
-2326
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ orbs:
77
defaults: &defaults
88
working_directory: ~/repo
99
docker:
10-
- image: cimg/node:18.15.0
10+
- image: cimg/node:18.20.3
1111
- image: mongo:7.0.0-rc5-jammy
1212

1313
jobs:

.solcover.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
module.exports = {
2+
mocha: {
3+
grep: "@skip-on-coverage", // Find everything with this tag
4+
invert: true // Run the grep's inverse set.
5+
},
26
skipFiles: [
37
'utils/StringUtils.sol',
48
'token/mocks',

contracts/access/AAccessControlled.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44
import { IZNSAccessController } from "./IZNSAccessController.sol";
5+
import { ZeroAddressPassed } from "../utils/CommonErrors.sol";
56

67

78
/**
@@ -11,7 +12,6 @@ import { IZNSAccessController } from "./IZNSAccessController.sol";
1112
* this contract needs to be inherited by the module.
1213
*/
1314
abstract contract AAccessControlled {
14-
1515
/**
1616
* @notice Emitted when the access controller contract address is set.
1717
*/
@@ -66,7 +66,7 @@ abstract contract AAccessControlled {
6666
* @param _accessController Address of the ZNSAccessController contract.
6767
*/
6868
function _setAccessController(address _accessController) internal {
69-
require(_accessController != address(0), "AC: _accessController is 0x0 address");
69+
if (_accessController == address(0)) revert ZeroAddressPassed();
7070
accessController = IZNSAccessController(_accessController);
7171
emit AccessControllerSet(_accessController);
7272
}

contracts/access/IZNSAccessController.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

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

contracts/access/ZNSAccessController.sol

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
55
import { IZNSAccessController } from "./IZNSAccessController.sol";
66
import { ZNSRoles } from "./ZNSRoles.sol";
7+
import { ZeroAddressPassed } from "../utils/CommonErrors.sol";
78

89

910
/**
@@ -77,10 +78,8 @@ contract ZNSAccessController is AccessControl, ZNSRoles, IZNSAccessController {
7778
function _grantRoleToMany(bytes32 role, address[] memory addresses) internal {
7879
uint256 length = addresses.length;
7980
for (uint256 i = 0; i < length; ++i) {
80-
require(
81-
addresses[i] != address(0),
82-
"ZNSAccessController: Can't grant role to zero address"
83-
);
81+
if (addresses[i] == address(0)) revert ZeroAddressPassed();
82+
8483
_grantRole(role, addresses[i]);
8584
}
8685
}

contracts/access/ZNSRoles.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44

55
/**

contracts/oz-proxies/ERC1967ProxyAcc.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44
// solhint-disable-next-line no-global-import
55
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

contracts/oz-proxies/TransparentUpgradeableProxyAcc.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44
// solhint-disable-next-line no-global-import
55
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contracts/price/IZNSCurvePricer.sol

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

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

77

88
interface IZNSCurvePricer is ICurvePriceConfig, IZNSPricer {
99

10+
/**
11+
* @notice Reverted when multiplier passed by the domain owner
12+
* is equal to 0 or more than 10^18, which is too large.
13+
*/
14+
error InvalidMultiplierPassed(uint256 multiplier);
15+
16+
/**
17+
* @notice Reverted when `priceConfig` set by the owner does not result in a proper asymptotic curve
18+
* and one of it's incorrect values causes the price spike at maxLength, meaning that the price
19+
* for a domain label shorter than `baseLength` (the one before `minPrice`) becomes higher than `minPrice`.
20+
*/
21+
error InvalidConfigCausingPriceSpikes(
22+
bytes32 configsDomainHash,
23+
uint256 minPrice,
24+
uint256 previousToMinPrice
25+
);
26+
1027
/**
1128
* @notice Emitted when the `maxPrice` is set in `CurvePriceConfig`
1229
* @param price The new maxPrice value

contracts/price/IZNSFixedPricer.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

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

contracts/price/ZNSCurvePricer.sol

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

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

8380
if (!skipValidityCheck) {
8481
// Confirms string values are only [a-z0-9-]
@@ -256,8 +253,8 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
256253
bytes32 domainHash,
257254
uint256 multiplier
258255
) public override onlyOwnerOrOperator(domainHash) {
259-
require(multiplier != 0, "ZNSCurvePricer: precisionMultiplier cannot be 0");
260-
require(multiplier <= 10**18, "ZNSCurvePricer: precisionMultiplier cannot be greater than 10^18");
256+
if (multiplier == 0 || multiplier > 10**18) revert InvalidMultiplierPassed(multiplier);
257+
261258
priceConfigs[domainHash].precisionMultiplier = multiplier;
262259

263260
emit PrecisionMultiplierSet(domainHash, multiplier);
@@ -275,10 +272,8 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
275272
public
276273
override
277274
onlyOwnerOrOperator(domainHash) {
278-
require(
279-
feePercentage <= PERCENTAGE_BASIS,
280-
"ZNSCurvePricer: feePercentage cannot be greater than PERCENTAGE_BASIS"
281-
);
275+
if (feePercentage > PERCENTAGE_BASIS)
276+
revert FeePercentageValueTooLarge(feePercentage, PERCENTAGE_BASIS);
282277

283278
priceConfigs[domainHash].feePercentage = feePercentage;
284279
emit FeePercentageSet(domainHash, feePercentage);
@@ -337,10 +332,12 @@ contract ZNSCurvePricer is AAccessControlled, ARegistryWired, UUPSUpgradeable, I
337332
*/
338333
function _validateConfig(bytes32 domainHash) internal view {
339334
uint256 prevToMinPrice = _getPrice(domainHash, priceConfigs[domainHash].maxLength);
340-
require(
341-
priceConfigs[domainHash].minPrice <= prevToMinPrice,
342-
"ZNSCurvePricer: incorrect value set causes the price spike at maxLength."
343-
);
335+
if (priceConfigs[domainHash].minPrice > prevToMinPrice)
336+
revert InvalidConfigCausingPriceSpikes(
337+
domainHash,
338+
priceConfigs[domainHash].minPrice,
339+
prevToMinPrice
340+
);
344341
}
345342

346343
/**

contracts/price/ZNSFixedPricer.sol

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

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

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

169164
priceConfigs[domainHash].feePercentage = feePercentage;
170165
emit FeePercentageSet(domainHash, feePercentage);

contracts/registrar/IZNSRootRegistrar.sol

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44
import { IDistributionConfig } from "../types/IDistributionConfig.sol";
55
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
@@ -42,13 +42,19 @@ struct CoreRegisterArgs {
4242
* + `isStakePayment`: A flag for whether the payment is a stake payment or not
4343
*/
4444
interface IZNSRootRegistrar is IDistributionConfig {
45+
error NotTheOwnerOf(
46+
OwnerOf ownerOf,
47+
address candidate,
48+
bytes32 domainHash
49+
);
50+
51+
error InvalidOwnerOfEnumValue(OwnerOf value);
4552

4653
enum OwnerOf {
4754
NAME,
4855
TOKEN,
4956
BOTH
5057
}
51-
5258
/**
5359
* @notice Emitted when a NEW domain is registered.
5460
* @dev `domainAddress` parameter is the address to which a domain name will relate to in ZNS.

contracts/registrar/IZNSSubRegistrar.sol

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44
import { IDistributionConfig } from "../types/IDistributionConfig.sol";
55
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
@@ -10,6 +10,16 @@ import { IZNSPricer } from "../types/IZNSPricer.sol";
1010
* @title IZNSSubRegistrar.sol - Interface for the ZNSSubRegistrar contract responsible for registering subdomains.
1111
*/
1212
interface IZNSSubRegistrar is IDistributionConfig {
13+
/**
14+
* @notice Reverted when someone other than parent owner is trying to buy a subdomain under the parent that is locked\
15+
* or when the parent provided does not exist.
16+
*/
17+
error ParentLockedOrDoesntExist(bytes32 parentHash);
18+
19+
/**
20+
* @notice Reverted when the buyer of subdomain is not approved by the parent in it's mintlist.
21+
*/
22+
error SenderNotApprovedForPurchase(bytes32 parentHash, address sender);
1323

1424
/**
1525
* @notice Emitted when a new `DistributionConfig.pricerContract` is set for a domain.

contracts/registrar/ZNSRootRegistrar.sol

+21-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.18;
2+
pragma solidity 0.8.26;
33

44
import { AAccessControlled } from "../access/AAccessControlled.sol";
55
import { ARegistryWired } from "../registry/ARegistryWired.sol";
@@ -11,6 +11,7 @@ import { IZNSSubRegistrar } from "../registrar/IZNSSubRegistrar.sol";
1111
import { IZNSPricer } from "../types/IZNSPricer.sol";
1212
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
1313
import { StringUtils } from "../utils/StringUtils.sol";
14+
import { ZeroAddressPassed, DomainAlreadyExists } from "../utils/CommonErrors.sol";
1415

1516

1617
/**
@@ -100,10 +101,8 @@ contract ZNSRootRegistrar is
100101
// Create hash for given domain name
101102
bytes32 domainHash = keccak256(bytes(name));
102103

103-
require(
104-
!registry.exists(domainHash),
105-
"ZNSRootRegistrar: Domain already exists"
106-
);
104+
if (registry.exists(domainHash))
105+
revert DomainAlreadyExists(domainHash);
107106

108107
// Get price for the domain
109108
uint256 domainPrice = rootPricer.getPrice(0x0, name, true);
@@ -256,10 +255,8 @@ contract ZNSRootRegistrar is
256255
external
257256
override
258257
{
259-
require(
260-
isOwnerOf(domainHash, msg.sender, OwnerOf.BOTH),
261-
"ZNSRootRegistrar: Not the owner of both Name and Token"
262-
);
258+
if (!isOwnerOf(domainHash, msg.sender, OwnerOf.BOTH))
259+
revert NotTheOwnerOf(OwnerOf.BOTH, msg.sender, domainHash);
263260

264261
subRegistrar.clearMintlistAndLock(domainHash);
265262
_coreRevoke(domainHash, msg.sender);
@@ -305,10 +302,9 @@ contract ZNSRootRegistrar is
305302
external
306303
override
307304
{
308-
require(
309-
isOwnerOf(domainHash, msg.sender, OwnerOf.TOKEN),
310-
"ZNSRootRegistrar: Not the owner of the Token"
311-
);
305+
if (!isOwnerOf(domainHash, msg.sender, OwnerOf.TOKEN))
306+
revert NotTheOwnerOf(OwnerOf.TOKEN, msg.sender, domainHash);
307+
312308
registry.updateDomainOwner(domainHash, msg.sender);
313309

314310
emit DomainReclaimed(domainHash, msg.sender);
@@ -330,7 +326,7 @@ contract ZNSRootRegistrar is
330326
&& candidate == domainToken.ownerOf(uint256(domainHash));
331327
}
332328

333-
revert("Wrong enum value for `ownerOf`");
329+
revert InvalidOwnerOfEnumValue(ownerOf);
334330
}
335331

336332
/**
@@ -348,10 +344,9 @@ contract ZNSRootRegistrar is
348344
* @param rootPricer_ Address of the IZNSPricer type contract to set as pricer of Root Domains
349345
*/
350346
function setRootPricer(address rootPricer_) public override onlyAdmin {
351-
require(
352-
rootPricer_ != address(0),
353-
"ZNSRootRegistrar: rootPricer_ is 0x0 address"
354-
);
347+
if (rootPricer_ == address(0))
348+
revert ZeroAddressPassed();
349+
355350
rootPricer = IZNSPricer(rootPricer_);
356351

357352
emit RootPricerSet(rootPricer_);
@@ -363,10 +358,9 @@ contract ZNSRootRegistrar is
363358
* @param treasury_ Address of the `ZNSTreasury` contract
364359
*/
365360
function setTreasury(address treasury_) public override onlyAdmin {
366-
require(
367-
treasury_ != address(0),
368-
"ZNSRootRegistrar: treasury_ is 0x0 address"
369-
);
361+
if (treasury_ == address(0))
362+
revert ZeroAddressPassed();
363+
370364
treasury = IZNSTreasury(treasury_);
371365

372366
emit TreasurySet(treasury_);
@@ -378,10 +372,9 @@ contract ZNSRootRegistrar is
378372
* @param domainToken_ Address of the `ZNSDomainToken` contract
379373
*/
380374
function setDomainToken(address domainToken_) public override onlyAdmin {
381-
require(
382-
domainToken_ != address(0),
383-
"ZNSRootRegistrar: domainToken_ is 0x0 address"
384-
);
375+
if (domainToken_ == address(0))
376+
revert ZeroAddressPassed();
377+
385378
domainToken = IZNSDomainToken(domainToken_);
386379

387380
emit DomainTokenSet(domainToken_);
@@ -392,7 +385,8 @@ contract ZNSRootRegistrar is
392385
* @param subRegistrar_ Address of the `ZNSSubRegistrar` contract
393386
*/
394387
function setSubRegistrar(address subRegistrar_) external override onlyAdmin {
395-
require(subRegistrar_ != address(0), "ZNSRootRegistrar: subRegistrar_ is 0x0 address");
388+
if (subRegistrar_ == address(0))
389+
revert ZeroAddressPassed();
396390

397391
subRegistrar = IZNSSubRegistrar(subRegistrar_);
398392
emit SubRegistrarSet(subRegistrar_);

0 commit comments

Comments
 (0)