Skip to content

Conversation

@MichaelKorchagin
Copy link
Collaborator

No description provided.

…r optimization according to registration and revocation.
…s. Adjusted distrConfig setter for Domain class. WIP
@Whytecrowe Whytecrowe requested a review from Copilot October 6, 2025 21:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Improves test coverage and refactors the Domain test helper to use object parameter patterns while adding new helper methods; introduces a comprehensive ZNSSubRegistrar unit test suite and adjusts existing tests to the new Domain API. Key changes include: refactoring Domain helper method signatures, adding retrieval and state mutation helpers, and expanding sub-registrar test scenarios (bulk + nested registration, config mutation, and access control behaviors).

  • Refactored Domain helper methods to accept single object params and added config/query utilities.
  • Added extensive ZNSSubRegistrar.unit.test.ts covering bulk registration, nested domains, and state mutation paths.
  • Updated existing tests (RootRegistrar, AddressResolver) to new Domain helper API and added minor type simplifications.

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/helpers/types.ts Narrowed pricerContract type; potential API restriction.
test/helpers/register-setup.ts Simplified approval flow; removed conditional allowance check.
test/helpers/domain/domain.ts Major refactor: new helper methods, object param signatures, pricing logic changes; introduced several logic issues.
test/helpers/deploy/deploy-zns.ts Removed unused import.
test/helpers/ac.ts Added file containing only commented-out (inactive) test scaffold.
test/ZNSSubRegistrar.unit.test.ts New comprehensive unit tests; contains a loop logic bug.
test/ZNSRootRegistrar.test.ts Updated calls to new Domain helper signatures; switched to helper getters.
test/ZNSAddressResolver.test.ts Updated operator-setting call to new object-style API.
test/DeployCampaignInt.test.ts Removed unused git tagging utility invocation/import.
Comments suppressed due to low confidence (1)

test/helpers/ac.ts:1

  • New file consists only of commented-out code; keeping inactive scaffolding increases noise and can confuse contributors. Remove the file or add active tests; if kept for future work, add a brief comment explaining its intentional placeholder status.
// import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 251 to 293
if (priceConfig ||
this.priceConfig !== undefined ||
Object.keys(this.priceConfig).length === 0
) {
const args = [this.hash];
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logical condition is flawed: (a) Object.keys(this.priceConfig) is accessed when this.priceConfig may be undefined (runtime TypeError), (b) using ORs makes the branch almost always true, and (c) when priceConfig is undefined you still cast and encode it at line 301 (likely undefined -> error). Replace with a guarded condition such as: if (priceConfig) { ... } else if (this.priceConfig) { reuse existing } else { throw error } and only call Object.keys after confirming existence.

Copilot uses AI. Check for mistakes.
this.priceConfig = decodePriceConfig(priceConfig);

} else {
args.push(encodePriceConfig(priceConfig as ICurvePriceConfig | IFixedPriceConfig));
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logical condition is flawed: (a) Object.keys(this.priceConfig) is accessed when this.priceConfig may be undefined (runtime TypeError), (b) using ORs makes the branch almost always true, and (c) when priceConfig is undefined you still cast and encode it at line 301 (likely undefined -> error). Replace with a guarded condition such as: if (priceConfig) { ... } else if (this.priceConfig) { reuse existing } else { throw error } and only call Object.keys after confirming existence.

Copilot uses AI. Check for mistakes.
Comment on lines 280 to 315
async setPricerDataForDomain ({
priceConfig,
pricerContract,
executor,
} : {
priceConfig ?: ICurvePriceConfig | IFixedPriceConfig | string;
pricerContract ?: string;
executor ?: SignerWithAddress;
}) {
if (priceConfig ||
this.priceConfig !== undefined ||
Object.keys(this.priceConfig).length === 0
) {
const args = [this.hash];

if (typeof priceConfig === "string") {
args.push(priceConfig);

this.priceConfig = decodePriceConfig(priceConfig);

} else {
args.push(encodePriceConfig(priceConfig as ICurvePriceConfig | IFixedPriceConfig));

this.priceConfig = priceConfig as ICurvePriceConfig | IFixedPriceConfig;
}

args.push(pricerContract ? pricerContract : this.distrConfig.pricerContract);

await this.zns.subRegistrar.connect(executor ? executor : this.owner).setPricerDataForDomain(
this.hash,
priceConfig ? encodePriceConfig(priceConfig) : encodePriceConfig(this.priceConfig),
pricerContract ? pricerContract : this.distrConfig.pricerContract
...args
);
} else {
throw new Error("Domain Helper: priceConfig is not specified");
}

// updating local var
if (priceConfig) {
this.priceConfig = priceConfig;
}
}

Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Allowing priceConfig to be either a structured config object or a pre-encoded string mixes responsibilities and weakens type safety. Consider splitting into two distinct methods (setPricerDataWithConfig vs setPricerDataWithBytes) or using a discriminated union to avoid ambiguous runtime branching.

Copilot uses AI. Check for mistakes.
});

// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = logs.length - 1; i === 0; i--) {
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loop condition uses i === 0, so it only executes when logs.length - 1 == 0 (single log); for multiple logs the body never runs. Replace condition with i >= 0 to iterate all logs in reverse.

Suggested change
for (let i = logs.length - 1; i === 0; i--) {
for (let i = logs.length - 1; i >= 0; i--) {

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (dbf2d7d) to head (47c8a50).

Additional details and impacted files
@@              Coverage Diff              @@
##           development      #161   +/-   ##
=============================================
  Coverage       100.00%   100.00%           
=============================================
  Files               13        13           
  Lines              596       596           
  Branches           137       137           
=============================================
  Hits               596       596           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants