Skip to content

fix: normalize network names in provider functions#54

Merged
rongquan1 merged 27 commits into
masterfrom
feat/matic-pol
Jun 9, 2026
Merged

fix: normalize network names in provider functions#54
rongquan1 merged 27 commits into
masterfrom
feat/matic-pol

Conversation

@manishdex25

@manishdex25 manishdex25 commented Jun 4, 2026

Copy link
Copy Markdown

Summary

What is the background of this pull request?

Changes

  • What are the changes made in this pull request?
  • Change this and that, etc...

Issues

What are the related issues or stories?

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Polygon ("pol") network recognition by normalizing network names to ensure proper provider initialization.
  • Tests

    • Enhanced test coverage for Polygon network support, including token registry verification and document validation scenarios.
    • Added comprehensive test fixtures for Polygon-specific document states.

@manishdex25 manishdex25 self-assigned this Jun 4, 2026
@manishdex25 manishdex25 requested a review from rongquan1 June 4, 2026 10:13
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Polygon ("pol") network support is introduced by normalizing the network name to "matic" before provider creation, then adding comprehensive token registry verification tests with Polygon-specific fixtures and assertions covering valid issuance, invalid registries, and issuer validation scenarios.

Changes

Polygon token registry verification support

Layer / File(s) Summary
Network name normalization for provider creation
src/common/utils.ts
normalizeNetworkName helper rewrites "pol" to "matic", applied in both getDefaultProvider and generateProvider before provider initialization.
Test infrastructure and provider initialization
src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts
Configures Polygon RPC URL, constructs Jest options with getDefaultProvider({ network: "pol" }), sets 300s timeout, and verifies provider creation for Polygon network.
Token registry verification unit tests
src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts
Implements test() and verify() unit test coverage for Ethereum token registry status verification, covering valid Polygon token registry documents, invalid/missing registries, unminted scenarios, issuer validation, and issuance method errors, all validated with inline snapshots.
Polygon token registry test fixtures
test/fixtures/v2/documentPolValidWithToken.ts, test/fixtures/v2/documentPolNotIssuedTokenRegistry.ts
Adds v2 OpenAttestation wrapped documents for Polygon mainnet: one representing a valid token-registry-issued document and another representing an issued but unminted scenario, both configured with recipient data, Merkle proofs, and DNS-TXT identity proofs.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 A Polygon path now shines so bright,
"pol" becomes "matic" in the night,
Token registries verified with care,
Fixtures and tests everywhere!
The network normalizes with delight. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is entirely a template with no actual content filled in. All sections are empty placeholders, providing no information about the background, specific changes, or related issues. Fill in the description template with actual content: explain the background (why network name normalization is needed), list the specific changes made, and reference any related issues or tickets.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: normalizing network names in provider functions, which is reflected in the utils.ts file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/matic-pol

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/common/utils.ts (1)

33-34: ⚡ Quick win

Add test coverage for network name normalization.

The normalizeNetworkName function lacks test coverage. Consider adding tests to verify:

  • Normalization of "pol" to "matic"
  • Pass-through of other network names unchanged
  • Case handling (once case-insensitivity is implemented)
  • Integration with both getDefaultProvider and generateProvider

Would you like me to generate unit tests for the normalization function?

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/common/utils.ts` around lines 33 - 34, Add unit tests for
normalizeNetworkName: create tests that assert normalizeNetworkName("pol") ===
"matic" and that other inputs (e.g., "mainnet", "rinkeby") return unchanged
values; add a case-insensitivity test once the function is updated (e.g., "Pol"
-> "matic") or mark as pending if not implemented. Also add integration tests
that call getDefaultProvider and generateProvider with network="pol" to ensure
they internally use normalizeNetworkName and produce the same provider as when
called with "matic". Reference the normalizeNetworkName function plus
getDefaultProvider and generateProvider in your test file and use the existing
test harness/assertion utilities used elsewhere in the repo.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/common/utils.ts`:
- Around line 33-34: The normalizeNetworkName function is currently
case-sensitive and won't map "POL"/"Pol"/other casings to "matic"; update
normalizeNetworkName to perform a case-insensitive comparison (e.g., normalize
input with network.toLowerCase()) and return "matic" when the lowercased value
equals "pol", otherwise return the original network; locate the helper named
normalizeNetworkName in src/common/utils.ts and adjust its logic accordingly.

---

Nitpick comments:
In `@src/common/utils.ts`:
- Around line 33-34: Add unit tests for normalizeNetworkName: create tests that
assert normalizeNetworkName("pol") === "matic" and that other inputs (e.g.,
"mainnet", "rinkeby") return unchanged values; add a case-insensitivity test
once the function is updated (e.g., "Pol" -> "matic") or mark as pending if not
implemented. Also add integration tests that call getDefaultProvider and
generateProvider with network="pol" to ensure they internally use
normalizeNetworkName and produce the same provider as when called with "matic".
Reference the normalizeNetworkName function plus getDefaultProvider and
generateProvider in your test file and use the existing test harness/assertion
utilities used elsewhere in the repo.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5520cac3-7cbd-49bd-a74d-d7e788a532db

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2dea9 and 9d5a39a.

📒 Files selected for processing (1)
  • src/common/utils.ts

Comment thread src/common/utils.ts Outdated
manishdex25 and others added 2 commits June 4, 2026 22:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts`:
- Around line 7-8: The file ethereumPolTokenRegistryStatus.test.ts has Prettier
formatting violations (notably around the POL_RPC_URL declaration and several
test blocks) causing lint failures; run Prettier or the project's formatting
script on
src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts
and fix the whitespace/line-breaks so the const POL_RPC_URL and the affected
test declarations/assertions (the blocks around lines referencing POL_RPC_URL
and the multiple test cases) conform to the project's Prettier rules—ensure
consistent indentation, line breaks, and semicolon/quote usage so lint passes.
- Around line 7-16: The test currently falls back to a shared public RPC
(POL_RPC_URL) and runs live mainnet verification, causing flaky CI; change the
setup so POL_RPC_URL is not defaulted to "https://polygon-rpc.com" (remove the
hard fallback) and instead require an explicit environment variable or a test
gate to run network integration (e.g., only use generateProvider with
network:"pol" when RUN_NETWORK_TESTS or POL_RPC is set), and for the non-network
path use a mocked or in-memory provider; also wrap the live verification block
(the test logic around lines 62-80) behind the same gate so CI runs
deterministically.
- Around line 35-40: The test currently only constructs a closure from
verificationBuilder(openAttestationVerifiers, { network: "pol" }) so
getProvider(...) is never executed; update the test to actually invoke the
returned verifier to trigger provider initialization: call const verifier =
verificationBuilder(openAttestationVerifiers, { network: "pol" }); then await
verifier(mockDocument) (or verifier(someMinimalValidDocument)) and assert it
does not throw (or resolves) — ensure the test handles async (use async/await or
return the promise) and provide a minimal mock document suitable for
verification so the provider path is exercised.

In `@test/fixtures/v2/documentPolValidWithToken.ts`:
- Around line 17-18: The fixture contains Prettier formatting issues around the
YAML "version" key and several adjacent scalar lines (the long schema URI
strings) — run Prettier or manually normalize whitespace and quoting so the YAML
scalars conform to the project's Prettier rules (consistent indentation, no
trailing commas, and proper quoting), ensuring the "version" value and the other
multiline/long string entries match the style of other fixtures; after
reformatting, save the file and re-run lint/Prettier to confirm the formatting
errors are resolved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d99866c5-943c-461c-bbf6-ba5dbcc0f79e

📥 Commits

Reviewing files that changed from the base of the PR and between 2b99584 and 7124a6c.

📒 Files selected for processing (2)
  • src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts
  • test/fixtures/v2/documentPolValidWithToken.ts

Comment thread src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts Outdated
Comment thread src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts Outdated
Comment thread test/fixtures/v2/documentPolValidWithToken.ts Outdated
manishdex25 and others added 15 commits June 5, 2026 10:25
…istryStatus.test.ts

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…istryStatus.test.ts

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…istryStatus.test.ts

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…istryStatus.test.ts

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…istryStatus.test.ts

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…istryStatus.test.ts

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…istryStatus.test.ts

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…d enhance validation logic

- Replaced the v2 document fixture with the v3 version for testing.
- Improved test cases to validate fragment statuses and handle W3C VC documents.
- Added new tests for various scenarios including missing credential status and invalid document formats.
- Removed obsolete v2 document fixture file.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts (1)

63-85: Remove/replace redundant test() cases that mutate W3C credentialStatus (lines 63–85).
openAttestationEthereumTokenRegistryStatus.test() only checks whether the input is an OA wrapped v2/v3 document (and then v2: issuer has tokenRegistry, v3: openAttestationMetadata.proof.method === TokenRegistry). It never reads W3C credentialStatus, so for the existing W3C VC fixture (already rejected on the earlier test), these mutations can’t influence the result—drop them or switch to OA v2/v3 fixtures to exercise the real missing/incorrect tokenRegistry conditions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts`
around lines 63 - 85, The three redundant tests mutating W3C credentialStatus
should be removed or replaced because
openAttestationEthereumTokenRegistryStatus.test only inspects OA-wrapped
documents; update tests to use OA v2/v3 fixtures instead of the W3C fixture
(documentPolValidWithToken) and assert missing/incorrect tokenRegistry by
mutating the OA-specific fields: for v2 change issuer.tokenRegistry, for v3
change openAttestationMetadata.proof.method (TokenRegistry) and then call
openAttestationEthereumTokenRegistryStatus.test(...) to verify false; remove
references to credentialStatus in these cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts`:
- Line 18: The global jest.setTimeout(300_000) is applied to the whole file
including fast unit tests; move scoping so only the network tests get the long
timeout by removing the top-level jest.setTimeout and placing it inside the
describe block that runs network tests (e.g., add jest.setTimeout(300_000) at
the start of the network-specific describe or a beforeAll within that describe
that calls jest.setTimeout), leaving unit test describes untouched so they use
the default timeout; locate the existing jest.setTimeout call and the
network-related describe that contains the tests which hit the network to apply
this change.

---

Nitpick comments:
In
`@src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts`:
- Around line 63-85: The three redundant tests mutating W3C credentialStatus
should be removed or replaced because
openAttestationEthereumTokenRegistryStatus.test only inspects OA-wrapped
documents; update tests to use OA v2/v3 fixtures instead of the W3C fixture
(documentPolValidWithToken) and assert missing/incorrect tokenRegistry by
mutating the OA-specific fields: for v2 change issuer.tokenRegistry, for v3
change openAttestationMetadata.proof.method (TokenRegistry) and then call
openAttestationEthereumTokenRegistryStatus.test(...) to verify false; remove
references to credentialStatus in these cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 08278100-160b-421f-a8b0-a2fc98e033fa

📥 Commits

Reviewing files that changed from the base of the PR and between 7124a6c and 7603bba.

📒 Files selected for processing (4)
  • src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts
  • test/fixtures/v2/documentPolValidWithToken.ts
  • test/fixtures/v3/documentPolValidWithToken.json
  • test/fixtures/v3/documentPolValidWithToken.ts

Comment thread src/verifiers/documentStatus/tokenRegistry/ethereumPolTokenRegistryStatus.test.ts Outdated
manishdex25 and others added 6 commits June 8, 2026 18:24
…nd improve validation logic

- Replaced v3 document fixture with v2 versions for testing.
- Enhanced test cases to validate fragment statuses and handle various document scenarios.
- Removed obsolete v3 document fixture files.
- Updated test logic to ensure proper handling of documents with missing data and issuers.
…istryStatus.test.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…r Amoy token registry

- Added .yalc and yalc.lock to .gitignore for local environment configuration.
- Updated package.json to reference local dnsprove package.
- Updated package-lock.json to include fsevents module.
- Introduced new test fixtures for Amoy token registry scenarios, including valid and not issued documents.
- Added comprehensive tests for the Amoy network verification logic.
…ration

- Eliminated the normalizeNetworkName function call in getDefaultProvider and generateProvider.
- Simplified network handling by directly using the provided options or environment variables.
…ompatibility

- Deleted the commented-out normalization for "pol" to "matic" in utils.ts, simplifying the codebase.
- Updated the Amoy document verification test to check for a valid hash fragment status instead of just its existence.
- Modified the provider configuration in the Polygon network tests to use the jsonrpc provider directly with an explicit RPC URL, enhancing clarity and functionality.
- Changed the default Polygon RPC URL in the test file to use a new endpoint for improved reliability.
…ent handling

- Introduced a new JSON fixture for a valid Amoy document with token.
- Refactored the TypeScript file to import the document from the new JSON fixture, streamlining the code and improving maintainability.
- Updated the Polygon RPC URL in the test configuration for enhanced reliability.
@rongquan1 rongquan1 merged commit f72871c into master Jun 9, 2026
11 checks passed
@rongquan1 rongquan1 deleted the feat/matic-pol branch June 9, 2026 04:29
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 9.7.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants