Skip to content

feat: add support for Polygon (POL) network#147

Merged
rongquan1 merged 12 commits into
mainfrom
feat/matic-pol
Jun 10, 2026
Merged

feat: add support for Polygon (POL) network#147
rongquan1 merged 12 commits into
mainfrom
feat/matic-pol

Conversation

@manishdex25

@manishdex25 manishdex25 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

This change enhances clarity and consistency in network handling.

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

  • Chores

    • Polygon chain metadata updated to use "POL" as the displayed currency and label; backward-compatible "matic" alias retained.
    • Package version bumped to 2.14.0.
  • Bug Fixes

    • Network currency set now includes "POL" where previously omitted.
  • Tests

    • New and expanded fixtures and test suites added to validate POL (mainnet and Amoy) network configurations and verification behaviors.

This change enhances clarity and consistency in network handling.
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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

Adds pol network identifier and POL currency; updates CHAIN_ID/SUPPORTED_CHAINS for Polygon (137) and Amoy to POL metadata; adds POL and Amoy fixtures and extensive Vitest suites; updates token-registry utilities for gas/bytecode/implementation handling; and surfaces POLYGONSCAN CI secret.

Changes

Polygon POL Nomenclature Migration

Layer / File(s) Summary
Network currency type update
src/utils/network/index.ts
networkCurrency union gains the 'POL' literal.
CHAIN_ID and SUPPORTED_CHAINS update
src/utils/supportedChains/index.ts
Add CHAIN_ID.pol = '137' (retain matic = '137' alias) and replace chain-137 SUPPORTED_CHAINS entries to use POL metadata and update Amoy explorer endpoints to Polygonscan.
supportedChains tests
src/utils/supportedChains/supportedChains.test.ts
Tests assert SUPPORTED_CHAINS fields for CHAIN_ID.pol, validate the matic alias returns identical data, confirm enum/mapping equality, and check Amoy Polygonscan explorer API presence and reachability.
POL & Amoy fixtures
src/__tests__/fixtures/fixtures.ts, src/__tests__/fixtures/*.json
Adds W3C_TRANSFERABLE_RECORD_POL SignedVerifiableCredential fixture and JSON fixtures for POL minted transferable record, OpenAttestation token-registry minted payload, POL verifiable document, and Amoy OA/W3C minted fixtures.
POL verification tests
src/__tests__/core/verify.pol.test.ts
New Vitest suite verifying CHAIN_ID.pol/alias and SUPPORTED_CHAINS mapping, fixture field checks, verifyDocument fragment assertions, tamper tests, and optional RPC-based on-chain checks via POL_RPC_URL.
Amoy verification tests
src/__tests__/core/verify.amoy.test.ts
New Vitest suite for Amoy (80002) with live and offline tests for OA token-registry and W3C transferable-record fixtures (gated by RUN_LIVE_TESTS).
Token-registry helper updates
src/token-registry-functions/utils.ts
getTxOptions short-circuits when gas inputs missing and converts fees to bigint for ethers v6; isSupportedTitleEscrowFactory now checks deployed bytecode and guards implementation() calls.
CI/workflow & metadata
.github/workflows/*, .gitignore, package.json
Add POLYGONSCAN_API_KEY to reusable tests workflow call/env, ignore .yalc/ artifacts, bump package version to 2.14.0 and update @tradetrust-tt/tt-verify to ^9.7.5.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • TrustVC/trustvc#78: Related token-registry utility changes touching src/token-registry-functions/utils.ts.
  • TrustVC/trustvc#96: Prior updates to token-registry-functions utilities that this PR builds on.
  • TrustVC/trustvc#79: Earlier edits to getTxOptions logic in src/token-registry-functions/utils.ts.

Suggested labels

released

Suggested reviewers

  • rongquan1
  • RishabhS7

Poem

"I’m a rabbit in the code, nibbling chains so bold,
From MATIC’s old charm to POL’s shiny gold. 🐇
I added tests and fixtures with care,
Kept aliases friendly — no bug to scare,
Now CI hums and wallets sing aloud."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description uses placeholder template sections without filling in actual details about the changes, background, or related issues. Replace placeholders with concrete information: describe the POL network support addition in Summary, list specific changes (currency type update, chain configuration, test additions), and reference related issues if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add support for Polygon (POL) network' directly and clearly summarizes the main change throughout the pull request - adding POL currency support and updating Polygon configuration.
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
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/utils/supportedChains/supportedChains.test.ts (1)

24-47: ⚡ Quick win

Strengthen POL migration coverage for renamed metadata fields.

Current assertions don’t verify the renamed display/native fields changed in config (Line 65 and Lines 74-75 in src/utils/supportedChains/index.ts). Adding those checks will better guard against partial reverts of the POL rename.

✅ Suggested test additions
   it('should return pol chain info for CHAIN_ID.pol (Polygon PoS mainnet)', () => {
-    const { id, name, type, currency, explorerUrl } = SUPPORTED_CHAINS[CHAIN_ID.pol];
+    const { id, name, type, currency, explorerUrl, label, nativeCurrency } =
+      SUPPORTED_CHAINS[CHAIN_ID.pol];

     expect(id).toBe(CHAIN_ID.pol);
     expect(name).toBe('pol');
     expect(type).toBe('production');
     expect(currency).toBe('POL');
     expect(explorerUrl).toBe('https://polygonscan.com');
+    expect(label).toBe('Polygon (POL)');
+    expect(nativeCurrency?.name).toBe('POL');
+    expect(nativeCurrency?.symbol).toBe('POL');
   });

   it('should return pol chain info when accessing via CHAIN_ID.matic (backward-compat alias for chain 137)', () => {
-    const { id, name, type, currency, explorerUrl } = SUPPORTED_CHAINS[CHAIN_ID.matic];
+    const { id, name, type, currency, explorerUrl, label, nativeCurrency } =
+      SUPPORTED_CHAINS[CHAIN_ID.matic];

     expect(id).toBe(CHAIN_ID.pol);
     expect(name).toBe('pol');
     expect(type).toBe('production');
     expect(currency).toBe('POL');
     expect(explorerUrl).toBe('https://polygonscan.com');
+    expect(label).toBe('Polygon (POL)');
+    expect(nativeCurrency?.name).toBe('POL');
+    expect(nativeCurrency?.symbol).toBe('POL');
   });
🤖 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/utils/supportedChains/supportedChains.test.ts` around lines 24 - 47, Add
assertions that verify the renamed display/native metadata fields on the POL
entry and its matic alias: after pulling SUPPORTED_CHAINS[CHAIN_ID.pol] (and
SUPPORTED_CHAINS[CHAIN_ID.matic]) check the new fields (e.g. displayCurrency and
nativeCurrency — use the actual property names used in supportedChains/index.ts)
exist and equal the expected values for POL, and update the alias equality test
to also assert SUPPORTED_CHAINS[CHAIN_ID.pol].displayCurrency ===
SUPPORTED_CHAINS[CHAIN_ID.matic].displayCurrency and
SUPPORTED_CHAINS[CHAIN_ID.pol].nativeCurrency ===
SUPPORTED_CHAINS[CHAIN_ID.matic].nativeCurrency so the rename is covered for
both access paths.
🤖 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.

Nitpick comments:
In `@src/utils/supportedChains/supportedChains.test.ts`:
- Around line 24-47: Add assertions that verify the renamed display/native
metadata fields on the POL entry and its matic alias: after pulling
SUPPORTED_CHAINS[CHAIN_ID.pol] (and SUPPORTED_CHAINS[CHAIN_ID.matic]) check the
new fields (e.g. displayCurrency and nativeCurrency — use the actual property
names used in supportedChains/index.ts) exist and equal the expected values for
POL, and update the alias equality test to also assert
SUPPORTED_CHAINS[CHAIN_ID.pol].displayCurrency ===
SUPPORTED_CHAINS[CHAIN_ID.matic].displayCurrency and
SUPPORTED_CHAINS[CHAIN_ID.pol].nativeCurrency ===
SUPPORTED_CHAINS[CHAIN_ID.matic].nativeCurrency so the rename is covered for
both access paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c69f902-1558-4ef1-a422-950c08ef25e8

📥 Commits

Reviewing files that changed from the base of the PR and between e25106e and f339346.

📒 Files selected for processing (3)
  • src/utils/network/index.ts
  • src/utils/supportedChains/index.ts
  • src/utils/supportedChains/supportedChains.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/__tests__/core/verify.pol.test.ts`:
- Line 7: The test depends on a live Polygon RPC via the POL_RPC_URL constant,
which makes CI flaky; update the test to gate or skip live-network behavior when
a specific env flag is not set (e.g., RUN_LIVE_TESTS or POL_RPC_REAL=true).
Modify the file-level constant POL_RPC_URL and the related test block(s) in
src/__tests__/core/verify.pol.test.ts so that if the flag is absent the test
uses a mocked/local RPC or calls test.skip/describe.skip to bypass the live RPC
assertions; ensure the gating is applied for both the POL_RPC_URL usage and the
tests around the verifyPol* test cases that currently rely on lines ~60-75.
🪄 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: 6ed1d8c4-45c7-427b-b167-e7d648d28d14

📥 Commits

Reviewing files that changed from the base of the PR and between f339346 and b83869e.

📒 Files selected for processing (2)
  • src/__tests__/core/verify.pol.test.ts
  • src/__tests__/fixtures/fixtures.ts

Comment thread src/__tests__/core/verify.pol.test.ts Outdated
@manishdex25 manishdex25 self-assigned this Jun 5, 2026
@manishdex25 manishdex25 requested a review from rongquan1 June 5, 2026 05:07
- Added new fixtures for W3C Transferable Record and OA Token Registry minted on Polygon mainnet.
- Updated tests to validate error handling for missing tokenRegistry and tokenNetwork.chainId.
- Adjusted test expectations to ensure proper validation of tampered documents.
- Refactored existing tests to improve clarity and maintainability.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/token-registry-functions/utils.ts (1)

15-16: ⚠️ Potential issue | 🟠 Major

Fix gas option handling and error masking in getTxOptions / isSupportedTitleEscrowFactory

  • getTxOptions treats valid explicit 0/0n gas inputs as “missing” via if (!maxFeePerGas || !maxPriorityFeePerGas) and can end up returning {} instead of preserving the caller’s values (lines 15-16 and 25-26). Use nullish checks (== null) to distinguish missing vs real zero.
  • isSupportedTitleEscrowFactory uses a broad catch around implementation(), which can mask unrelated RPC/provider failures; preserve the original error (or narrow the catch) instead of always converting to the v5/v4 message.
if (!maxFeePerGas || !maxPriorityFeePerGas) {
  chainId = chainId ?? ((await getChainIdSafe(signer)) as unknown as CHAIN_ID);
Suggested fix
-  if (!maxFeePerGas || !maxPriorityFeePerGas) {
+  if (maxFeePerGas == null || maxPriorityFeePerGas == null) {
     chainId = chainId ?? ((await getChainIdSafe(signer)) as unknown as CHAIN_ID);
     const gasStation = SUPPORTED_CHAINS[chainId]?.gasStation;

     if (gasStation) {
       const gasFees = await gasStation();
-      maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
-      maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
+      maxFeePerGas = gasFees?.maxFeePerGas;
+      maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas;
     }
   }
-  if (!maxFeePerGas || !maxPriorityFeePerGas) {
+  if (maxFeePerGas == null || maxPriorityFeePerGas == null) {
     return {};
   }
🤖 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/token-registry-functions/utils.ts` around lines 15 - 16, The gas-option
check in getTxOptions incorrectly treats explicit zero values as missing;
replace the falsy checks on maxFeePerGas and maxPriorityFeePerGas (the `if
(!maxFeePerGas || !maxPriorityFeePerGas)` logic) with nullish checks (e.g., `==
null`) so 0/0n are preserved and chainId/fee lookups only happen when values are
truly absent; also ensure the function returns the caller-provided values rather
than an empty {}. In isSupportedTitleEscrowFactory, avoid the broad catch around
implementation() that masks RPC/provider errors: narrow the catch to only handle
the specific “method not found / v4” condition or rethrow non-matching errors
(i.e., inspect the caught error before mapping to the v5/v4 message) so
unrelated failures surface rather than being converted into the v5/v4 fallback.
♻️ Duplicate comments (1)
src/__tests__/core/verify.pol.test.ts (1)

308-341: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

“Structural” OA tests still depend on live Polygon RPC.

Line 308-341 runs even when RUN_LIVE_TESTS is false, and Line 12’s default public RPC keeps these tests network-bound/flaky in CI.

Suggested fix
-const POL_RPC_URL = process.env.POL_RPC || 'https://polygon-bor-rpc.publicnode.com';
+const POL_RPC_URL = process.env.POL_RPC;

-describe.skipIf(!OA_POL_MINTED_READY)(
+describe.skipIf(!OA_POL_MINTED_READY || !RUN_LIVE_TESTS || !POL_RPC_URL)(
   'pol-oa-token-registry-minted — structural (hash + verifier selection)',
   () => {

Also applies to: 12-12

🤖 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/__tests__/core/verify.pol.test.ts` around lines 308 - 341, The tests in
the describe.skipIf block (named 'pol-oa-token-registry-minted — structural
(hash + verifier selection)') still hit a live Polygon RPC because
verifyDocument is called with POL_RPC_URL by default; change the test guard so
these network-bound checks are skipped when RUN_LIVE_TESTS is not set/false.
Concretely, update the describe.skipIf predicate (or wrap the verifyDocument
calls) to use process.env.RUN_LIVE_TESTS (e.g.
describe.skipIf(!process.env.RUN_LIVE_TESTS)) or only pass rpcProviderUrl:
POL_RPC_URL when process.env.RUN_LIVE_TESTS === 'true'; adjust calls to
verifyDocument(polOaTokenRegistryMinted, { rpcProviderUrl: POL_RPC_URL }) and
related tampered test so they don't use POL_RPC_URL unless RUN_LIVE_TESTS is
enabled (keep test names like 'OpenAttestationHash' and
'OpenAttestationEthereumTokenRegistryStatus' unchanged).
🤖 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/__tests__/core/verify.pol.test.ts`:
- Around line 376-382: The test 'DOCUMENT_STATUS should be SKIPPED when no
credentialStatus' currently returns early if polW3cVerifiableDocument already
has credentialStatus, making the assertion a no-op; instead, create a copy of
polW3cVerifiableDocument (e.g., const doc = { ...polW3cVerifiableDocument }) and
explicitly delete or set doc.credentialStatus = undefined before calling
verifyDocument(doc), then assert that all fragments with type 'DOCUMENT_STATUS'
have status 'SKIPPED' using verifyDocument and the existing statusFragments
filtering; remove the early return so the test always performs the assertion.

In `@src/__tests__/fixtures/pol-w3c-verifiable-document.json`:
- Around line 44-52: The fixture incorrectly marks a non-transferable document
as transferable by setting credentialStatus.type to "TransferableRecords" and
including tokenNetwork/tokenRegistry/tokenId metadata; update the fixture so
credentialStatus either is removed or replaced with a non-transferable
representation (e.g., omit TransferableRecords and token* fields) to match the
non-transferable test intent, ensuring references to credentialStatus,
TransferableRecords, tokenNetwork, tokenRegistry, and tokenId are corrected
accordingly.

In `@src/token-registry-functions/utils.ts`:
- Around line 95-102: The current bare catch around calling
titleEscrowFactoryContract.implementation() masks all errors and always throws a
misleading "does not expose implementation()" message; update the catch to
inspect the caught error from the implementation() call (the thrown object from
ethers) and only translate it into the factory-missing-selector message when it
clearly indicates an ABI/selector/missing-function situation (e.g., message/code
indicating "missing revert", "method not found", "does not contain function", or
similar ABI-mismatch text), otherwise rethrow the original error (preferably by
throwing a new Error that includes the original error as the cause). Keep
references to titleEscrowFactoryContract.implementation(), factoryAddress and
implAddr when updating the logic so the specific ABI-mismatch is handled while
network/RPC/decoding errors bubble up with their original details.

---

Outside diff comments:
In `@src/token-registry-functions/utils.ts`:
- Around line 15-16: The gas-option check in getTxOptions incorrectly treats
explicit zero values as missing; replace the falsy checks on maxFeePerGas and
maxPriorityFeePerGas (the `if (!maxFeePerGas || !maxPriorityFeePerGas)` logic)
with nullish checks (e.g., `== null`) so 0/0n are preserved and chainId/fee
lookups only happen when values are truly absent; also ensure the function
returns the caller-provided values rather than an empty {}. In
isSupportedTitleEscrowFactory, avoid the broad catch around implementation()
that masks RPC/provider errors: narrow the catch to only handle the specific
“method not found / v4” condition or rethrow non-matching errors (i.e., inspect
the caught error before mapping to the v5/v4 message) so unrelated failures
surface rather than being converted into the v5/v4 fallback.

---

Duplicate comments:
In `@src/__tests__/core/verify.pol.test.ts`:
- Around line 308-341: The tests in the describe.skipIf block (named
'pol-oa-token-registry-minted — structural (hash + verifier selection)') still
hit a live Polygon RPC because verifyDocument is called with POL_RPC_URL by
default; change the test guard so these network-bound checks are skipped when
RUN_LIVE_TESTS is not set/false. Concretely, update the describe.skipIf
predicate (or wrap the verifyDocument calls) to use process.env.RUN_LIVE_TESTS
(e.g. describe.skipIf(!process.env.RUN_LIVE_TESTS)) or only pass rpcProviderUrl:
POL_RPC_URL when process.env.RUN_LIVE_TESTS === 'true'; adjust calls to
verifyDocument(polOaTokenRegistryMinted, { rpcProviderUrl: POL_RPC_URL }) and
related tampered test so they don't use POL_RPC_URL unless RUN_LIVE_TESTS is
enabled (keep test names like 'OpenAttestationHash' and
'OpenAttestationEthereumTokenRegistryStatus' unchanged).
🪄 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: 7c60a4f0-f7d6-462c-bc57-9f1ff6a85bd8

📥 Commits

Reviewing files that changed from the base of the PR and between 74088e1 and 7079568.

📒 Files selected for processing (7)
  • src/__tests__/core/verify.pol.test.ts
  • src/__tests__/fixtures/pol-oa-token-registry-minted.json
  • src/__tests__/fixtures/pol-w3c-transferable-record-minted.json
  • src/__tests__/fixtures/pol-w3c-verifiable-document.json
  • src/token-registry-functions/utils.ts
  • src/utils/supportedChains/index.ts
  • src/utils/supportedChains/supportedChains.test.ts
✅ Files skipped from review due to trivial changes (1)
  • src/tests/fixtures/pol-oa-token-registry-minted.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/utils/supportedChains/supportedChains.test.ts
  • src/utils/supportedChains/index.ts

Comment thread src/__tests__/core/verify.pol.test.ts Outdated
Comment thread src/__tests__/fixtures/pol-w3c-verifiable-document.json Outdated
Comment thread src/token-registry-functions/utils.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/utils/supportedChains/supportedChains.test.ts (1)

77-119: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Structural/offline tests are incorrectly skipped unless live tests are enabled.

These blocks are labeled structural/offline, but describe.skipIf(!RUN_LIVE_TESTS) prevents them from running in normal CI. This hides regressions in non-live verification paths.

Suggested change
-  describe.skipIf(!RUN_LIVE_TESTS)(
+  describe(
     'amoy-oa-token-registry-minted — structural (hash + verifier selection)',
     () => {
       ...
     },
   );

-  describe.skipIf(!RUN_LIVE_TESTS)(
+  describe(
     'amoy-w3c-transferable-record-minted — structural (offline)',
     () => {
       ...
     },
   );

Also applies to: 172-202

🤖 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/utils/supportedChains/supportedChains.test.ts` around lines 77 - 119, The
structural/offline test blocks are incorrectly wrapped with
describe.skipIf(!RUN_LIVE_TESTS) which skips them in normal CI; change those
blocks (where SUPPORTED_CHAINS is validated) to run unconditionally by replacing
describe.skipIf(!RUN_LIVE_TESTS) with a plain describe(...) (or another
unconditional test wrapper), leaving any true live-only blocks still guarded by
RUN_LIVE_TESTS; ensure you update every occurrence (including the other block
noted) so structural/offline checks always execute.
🤖 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/__tests__/core/verify.amoy.test.ts`:
- Around line 77-119: The test suite uses describe.skipIf(!RUN_LIVE_TESTS) which
skips offline/structural tests when RUN_LIVE_TESTS is false; change the
structural/offline describe blocks (the one titled
'amoy-oa-token-registry-minted — structural (hash + verifier selection)' and the
other at lines ~172-202) to use a plain describe (or a dedicated skip flag for
live-only tests) so they run in CI by default; update the calls around
describe.skipIf and keep the individual live/network-dependent it blocks using
RUN_LIVE_TESTS or conditional skips only where network RPC (verifyDocument with
rpcProviderUrl/AMOY_RPC_URL) is required, leaving pure structural tests
(OpenAttestationHash, tamper check, chainId decode) executed unconditionally;
look for symbols describe.skipIf, RUN_LIVE_TESTS, verifyDocument,
amoyOaTokenRegistryMinted and adjust the describe wrappers accordingly.
- Around line 9-10: The RUN_LIVE_TESTS flag is being set with truthy coercion
(const RUN_LIVE_TESTS = !!process.env.RUN_LIVE_TESTS) which treats values like
"false" as true; change the assignment to explicitly compare the environment
string to "true" (e.g., const RUN_LIVE_TESTS = process.env.RUN_LIVE_TESTS ===
'true') so only the literal "true" enables live tests; update any test logic
that relies on RUN_LIVE_TESTS to continue using that constant.

In `@src/utils/supportedChains/supportedChains.test.ts`:
- Around line 67-71: The test making a real network HEAD request (the it block
referencing SUPPORTED_CHAINS and CHAIN_ID.amoy) should not run by default;
change the test to either skip or only run when a live/network flag is set
(e.g., process.env.RUN_LIVE_TESTS) or replace the fetch call with a mocked
response using your test framework's mocking utilities so no external DNS/HTTP
call is made; update the test title/comment to reflect it's a gated live check
and keep references to SUPPORTED_CHAINS and CHAIN_ID.amoy so reviewers can find
the location.

---

Outside diff comments:
In `@src/utils/supportedChains/supportedChains.test.ts`:
- Around line 77-119: The structural/offline test blocks are incorrectly wrapped
with describe.skipIf(!RUN_LIVE_TESTS) which skips them in normal CI; change
those blocks (where SUPPORTED_CHAINS is validated) to run unconditionally by
replacing describe.skipIf(!RUN_LIVE_TESTS) with a plain describe(...) (or
another unconditional test wrapper), leaving any true live-only blocks still
guarded by RUN_LIVE_TESTS; ensure you update every occurrence (including the
other block noted) so structural/offline checks always execute.
🪄 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: 66a6a0f0-83ec-47d5-b822-50b073520abf

📥 Commits

Reviewing files that changed from the base of the PR and between 7079568 and bfc06d6.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • .github/workflows/ci.yml
  • .github/workflows/tests.yml
  • .gitignore
  • package.json
  • src/__tests__/core/verify.amoy.test.ts
  • src/__tests__/fixtures/amoy-oa-token-registry-minted.json
  • src/__tests__/fixtures/amoy-w3c-transferable-record-minted.json
  • src/utils/supportedChains/index.ts
  • src/utils/supportedChains/supportedChains.test.ts
✅ Files skipped from review due to trivial changes (2)
  • package.json
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/supportedChains/index.ts

Comment thread src/__tests__/core/verify.amoy.test.ts Outdated
Comment thread src/__tests__/core/verify.amoy.test.ts Outdated
Comment thread src/utils/supportedChains/supportedChains.test.ts Outdated
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@rongquan1 rongquan1 merged commit 4d07053 into main Jun 10, 2026
12 of 13 checks passed
@rongquan1 rongquan1 deleted the feat/matic-pol branch June 10, 2026 02:36
nghaninn pushed a commit that referenced this pull request Jun 10, 2026
## [2.14.0](v2.13.0...v2.14.0) (2026-06-10)

### Features

* add support for Polygon (POL) network ([#147](#147)) ([4d07053](4d07053))

### Miscellaneous Chores

* document did:key issuer support in README ([#146](#146)) ([e25106e](e25106e)), closes [#145](#145)
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.14.0 🎉

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.

3 participants