Skip to content

fix: did controller#347

Open
GHkrishna wants to merge 6 commits intofeat/oidc-main-syncfrom
fix/did-controller
Open

fix: did controller#347
GHkrishna wants to merge 6 commits intofeat/oidc-main-syncfrom
fix/did-controller

Conversation

@GHkrishna
Copy link
Contributor

@GHkrishna GHkrishna commented Mar 5, 2026

What:

  • fix did controller

Summary by CodeRabbit

  • New Features

    • Added Polygon DID support with new endpoints for creating Secp256k1 key pairs, creating W3C schemas, estimating transactions, and retrieving schema details.
  • Chores

    • Updated dependency versioning to allow compatible minor and patch updates for the Polygon W3C module.

Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
@GHkrishna GHkrishna requested a review from shitrerohit March 5, 2026 12:17
@GHkrishna GHkrishna self-assigned this Mar 5, 2026
@GHkrishna GHkrishna added the bug Something isn't working label Mar 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4969f936-a8b9-4ece-adb5-63c39916f53e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR enables Polygon DID support in the agent by updating the polygon module dependency constraint from exact to flexible versioning, adding Polygon registrars and resolvers to the DID configuration, instantiating and configuring the PolygonModule with contract addresses and RPC settings, and introducing new API routes and OpenAPI documentation for Polygon operations including key creation, schema management, transaction estimation, and schema retrieval.

Changes

Cohort / File(s) Summary
Dependency Management
package.json
Updated @ayanworks/credo-polygon-w3c-module version constraint from exact (2.0.0) to flexible (^2.0.0), allowing minor and patch version updates.
Module Configuration
src/cliAgent.ts, src/utils/agent.ts
Added imports for PolygonDidRegistrar, PolygonDidResolver, and PolygonModule; integrated Polygon support into DID registrars and resolvers arrays; instantiated and configured PolygonModule with contract addresses, tokens, and RPC/server URLs from parameters or environment variables.
API Routes & Schema
src/routes/routes.ts
Added PolygonController import; introduced model definitions for DID operations (Create, Update, Deactivate, AddResource) and related operation option types; registered four new Polygon endpoints for key creation, schema creation, transaction estimation, and schema retrieval.
API Documentation
src/routes/swagger.json
Added comprehensive OpenAPI schema definitions for Polygon DID operations, record types, and operation options; documented four new endpoints under /polygon path with request/response schemas and JWT security requirements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #345: Upgrades and modifies imports/paths for @ayanworks/credo-polygon-w3c-module, providing the foundation for Polygon integration enabled in this PR.

Suggested labels

chore

Suggested reviewers

  • shitrerohit
  • RinkalBhojani

Poem

🐰 A polygon dream, now taking flight,
With registrars shining crystal bright,
DIDs dancing on the blockchain's stage,
Keys and schemas turn each page,
Hop along this web3 delight! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: did controller' is vague and generic, failing to describe the specific changes made. The PR primarily adds Polygon DID support with new routes, schemas, and module integrations, but the title provides no meaningful insight into these substantial changes. Consider a more descriptive title such as 'fix: add Polygon DID support with resolver, registrar, and routes' to clearly convey the primary changes and improvements.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/did-controller

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.

@GHkrishna
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1 similar comment
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

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

⚠️ Outside diff range comments (1)
src/cliAgent.ts (1)

174-186: ⚠️ Potential issue | 🟡 Minor

Add trailing commas to satisfy formatter checks.

Line 178 and Line 185 are missing trailing commas and currently fail Prettier.

Suggested fix
       registrars: [
         new IndyVdrIndyDidRegistrar(),
         new KeyDidRegistrar(),
         new JwkDidRegistrar(),
-        new PolygonDidRegistrar()
+        new PolygonDidRegistrar(),
       ],
       resolvers: [
         new IndyVdrIndyDidResolver(),
         new KeyDidResolver(),
         new WebDidResolver(),
         new JwkDidResolver(),
-        new PolygonDidResolver()
+        new PolygonDidResolver(),
       ],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cliAgent.ts` around lines 174 - 186, Add trailing commas to the arrays in
the registrars and resolvers object so Prettier passes; specifically, update the
registrars array (after PolygonDidRegistrar()) and the resolvers array (after
PolygonDidResolver()) in src/cliAgent.ts to include a trailing comma each,
ensuring the entries for new PolygonDidRegistrar() and new PolygonDidResolver()
end with commas.
🧹 Nitpick comments (1)
src/routes/swagger.json (1)

3807-3812: Polygon 200 responses use empty schemas (schema: {}), which weakens API contract documentation and client type generation.

The three endpoints /polygon/create-schema (POST), /polygon/estimate-transaction (POST), and /polygon/{did}/{schemaId} (GET) all return untyped responses. The Record_string.unknown_ schema exists in components and can be referenced to provide proper typing.

🔧 Suggested schema contract improvement
"/polygon/create-schema": {
  "post": {
    "responses": {
      "200": {
        "description": "Schema JSON",
        "content": {
          "application/json": {
-           "schema": {}
+           "schema": {
+             "$ref": "#/components/schemas/Record_string.unknown_"
+           }
          }
        }
      }
    }
  }
},
"/polygon/estimate-transaction": {
  "post": {
    "responses": {
      "200": {
        "description": "Transaction Object",
        "content": {
          "application/json": {
-           "schema": {}
+           "schema": {
+             "$ref": "#/components/schemas/Record_string.unknown_"
+           }
          }
        }
      }
    }
  }
},
"/polygon/{did}/{schemaId}": {
  "get": {
    "responses": {
      "200": {
        "description": "Schema Object",
        "content": {
          "application/json": {
-           "schema": {}
+           "schema": {
+             "$ref": "#/components/schemas/Record_string.unknown_"
+           }
          }
        }
      }
    }
  }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/swagger.json` around lines 3807 - 3812, The 200 responses for the
Polygon endpoints are using empty schemas (schema: {}); update the OpenAPI
response objects for the three paths "/polygon/create-schema" (POST),
"/polygon/estimate-transaction" (POST), and "/polygon/{did}/{schemaId}" (GET) to
reference the existing components schema "Record_string.unknown_" instead of an
empty object so clients and generated types get proper typing; locate the
response objects in swagger.json for those paths and replace the empty "schema":
{} entries under "content": {"application/json"} with a $ref to
"#/components/schemas/Record_string.unknown_".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 42: The dependency entry for "@ayanworks/credo-polygon-w3c-module" is
pinned to ^2.0.0 which doesn't exist; update that dependency value in
package.json to a published version (e.g., "^1.0.0" or "1.0.0") so npm install
can succeed, then regenerate lockfile by running npm install (or yarn install)
to update package-lock.json/yarn.lock accordingly.

In `@src/cliAgent.ts`:
- Line 68: The import statement for PolygonDidRegistrar, PolygonDidResolver,
PolygonModule from '@ayanworks/credo-polygon-w3c-module' is in the wrong import
group; move that line into the external (third-party) imports block so it obeys
the import/order rule. Locate the import of "PolygonDidRegistrar,
PolygonDidResolver, PolygonModule" in src/cliAgent.ts and place it with other
external package imports (not with local/internal or parent imports) ensuring
any alphabetization/grouping used by the file's existing import ordering is
preserved.
- Around line 240-249: The PolygonModule is being passed values that use `as
string` fallbacks which can hide missing envs; update the initialization where
`polygon: new PolygonModule({ ... })` is constructed to call the codebase's
requireEnv helper for required settings (e.g. DID_CONTRACT_ADDRESS,
SCHEMA_MANAGER_CONTRACT_ADDRESS, FILE_SERVER_TOKEN, RPC_URL, SERVER_URL) when
the corresponding CLI variables (didRegistryContractAddress,
schemaManagerContractAddress, fileServerToken, rpcUrl, fileServerUrl) are not
provided, so that requireEnv(...) throws immediately on missing configuration
instead of passing undefined strings into PolygonModule.

In `@src/routes/routes.ts`:
- Around line 9-10: The routes import and DI resolution reference the Polygon
controller symbol (import { Polygon } and container.get<Polygon>(Polygon)) but
the PolygonController implementation/export is commented out, causing
build/runtime failures; restore or re-export the Polygon controller class with
its routed methods (ensure class name matches Polygon or update the import),
then re-run tsoa to regenerate routes so the auto-generated routes.ts and
container resolution align (verify PolygonController exports the expected
methods used by routes and that the symbol name matches the import/container.get
usage).

In `@src/routes/swagger.json`:
- Around line 485-488: The swagger schema for the "resource" property currently
disallows any properties (it declares "type": "object" with
"additionalProperties": false), which blocks real addResource payloads; update
the "resource" schema used by the addResource operation to either (a) remove
"additionalProperties": false so arbitrary resource fields are allowed, (b) set
"additionalProperties": true to permit dynamic properties, or (c) explicitly
declare the expected properties and their types under "resource" so valid
payloads can pass validation; adjust the "required" list accordingly if needed.

In `@src/utils/agent.ts`:
- Line 33: The import for PolygonModule ("import { PolygonModule } from
'@ayanworks/credo-polygon-w3c-module'") is out of order and triggers the
import/order ESLint rule; move that line into the correct import group with
other third-party/externals (keeping it with other node_modules imports), ensure
it follows the project's import grouping and ordering style, and then run ESLint
or use the project's import sorter to reformat imports so the import/order rule
passes.
- Around line 130-136: The PolygonModule is being instantiated with empty
strings; replace those hardcoded empty values by reading the corresponding
environment variables (e.g., process.env.DID_CONTRACT_ADDRESS,
process.env.SCHEMA_MANAGER_CONTRACT_ADDRESS, process.env.FILE_SERVER_TOKEN,
process.env.POLYGON_RPC_URL or similar RPC env var, and
process.env.POLYGON_SERVER_URL) when constructing PolygonModule in the
PolygonModule(...) call, and perform a fail-fast check (throw an error or exit)
if any required env var is missing so the app fails at startup rather than
causing runtime failures.

---

Outside diff comments:
In `@src/cliAgent.ts`:
- Around line 174-186: Add trailing commas to the arrays in the registrars and
resolvers object so Prettier passes; specifically, update the registrars array
(after PolygonDidRegistrar()) and the resolvers array (after
PolygonDidResolver()) in src/cliAgent.ts to include a trailing comma each,
ensuring the entries for new PolygonDidRegistrar() and new PolygonDidResolver()
end with commas.

---

Nitpick comments:
In `@src/routes/swagger.json`:
- Around line 3807-3812: The 200 responses for the Polygon endpoints are using
empty schemas (schema: {}); update the OpenAPI response objects for the three
paths "/polygon/create-schema" (POST), "/polygon/estimate-transaction" (POST),
and "/polygon/{did}/{schemaId}" (GET) to reference the existing components
schema "Record_string.unknown_" instead of an empty object so clients and
generated types get proper typing; locate the response objects in swagger.json
for those paths and replace the empty "schema": {} entries under "content":
{"application/json"} with a $ref to
"#/components/schemas/Record_string.unknown_".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e5c246a7-5258-4039-b633-eddeaab6f211

📥 Commits

Reviewing files that changed from the base of the PR and between 134e298 and 0f240f5.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • package.json
  • src/cliAgent.ts
  • src/routes/routes.ts
  • src/routes/swagger.json
  • src/utils/agent.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (7)
src/utils/agent.ts (2)

33-33: ⚠️ Potential issue | 🟡 Minor

Fix external import grouping for PolygonModule.

Line 33 is still below a local import and continues to violate import/order.

Suggested fix
 import type { InitConfig } from '@credo-ts/core'
+import { PolygonModule } from '@ayanworks/credo-polygon-w3c-module'
@@
 import { TsLogger } from './logger'
-import { PolygonModule } from '@ayanworks/credo-polygon-w3c-module'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/agent.ts` at line 33, The import for PolygonModule is placed after
a local import and violates import/order; move the line importing PolygonModule
from '@ayanworks/credo-polygon-w3c-module' into the external (third-party)
imports block so it appears with other external dependencies (above any
local/project-relative imports), then re-run the linter/formatter to ensure
import/order is satisfied; reference the PolygonModule import statement to
locate and relocate it.

130-136: ⚠️ Potential issue | 🟠 Major

Avoid booting PolygonModule with empty required config.

Lines 130-135 pass hardcoded empty strings, which will defer failure to runtime. Load required env values and fail fast during startup.

Suggested fix
+const requireEnv = (name: string): string => {
+  const value = process.env[name]
+  if (!value) throw new Error(`Missing environment variable: ${name}`)
+  return value
+}
+
@@
       polygon: new PolygonModule({
-        didContractAddress: '',
-        schemaManagerContractAddress: '',
-        fileServerToken: '',
-        rpcUrl: '',
-        serverUrl: '',
+        didContractAddress: requireEnv('DID_CONTRACT_ADDRESS'),
+        schemaManagerContractAddress: requireEnv('SCHEMA_MANAGER_CONTRACT_ADDRESS'),
+        fileServerToken: requireEnv('FILE_SERVER_TOKEN'),
+        rpcUrl: requireEnv('RPC_URL'),
+        serverUrl: requireEnv('SERVER_URL'),
       }),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/agent.ts` around lines 130 - 136, PolygonModule is being
instantiated with empty strings for required config, which defers errors to
runtime; update the initialization to read the required environment/config
values (didContractAddress, schemaManagerContractAddress, fileServerToken,
rpcUrl, serverUrl) and validate them before constructing PolygonModule (e.g.,
throw or log fatal and exit if any are missing/invalid) so startup fails fast;
locate the PolygonModule instantiation and replace the hardcoded empty values
with the validated config variables (and add a short helper or inline checks to
surface a clear error if any required value is absent).
src/cliAgent.ts (2)

68-68: ⚠️ Potential issue | 🟡 Minor

Reorder Polygon import to satisfy import/order.

Line 68 is still out of the external import grouping and will keep lint failing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cliAgent.ts` at line 68, The import for PolygonDidRegistrar,
PolygonDidResolver, PolygonModule is currently misplaced and violating
import/order; move the line "import { PolygonDidRegistrar, PolygonDidResolver,
PolygonModule } from '@ayanworks/credo-polygon-w3c-module'" into the
external-imports group with the other third-party imports (keeping a single
blank line between external and internal imports) so the external grouping order
is preserved and the linter passes.

240-249: ⚠️ Potential issue | 🟠 Major

Fail fast for required Polygon config instead of using as string fallbacks.

These assertions can hide missing env vars and pass invalid runtime config into module initialization.

Suggested fix
     polygon: new PolygonModule({
-      didContractAddress: didRegistryContractAddress
-        ? didRegistryContractAddress
-        : (process.env.DID_CONTRACT_ADDRESS as string),
-      schemaManagerContractAddress:
-        schemaManagerContractAddress || (process.env.SCHEMA_MANAGER_CONTRACT_ADDRESS as string),
-      fileServerToken: fileServerToken ? fileServerToken : (process.env.FILE_SERVER_TOKEN as string),
-      rpcUrl: rpcUrl ? rpcUrl : (process.env.RPC_URL as string),
-      serverUrl: fileServerUrl ? fileServerUrl : (process.env.SERVER_URL as string),
+      didContractAddress: didRegistryContractAddress || requireEnv('DID_CONTRACT_ADDRESS'),
+      schemaManagerContractAddress:
+        schemaManagerContractAddress || requireEnv('SCHEMA_MANAGER_CONTRACT_ADDRESS'),
+      fileServerToken: fileServerToken || requireEnv('FILE_SERVER_TOKEN'),
+      rpcUrl: rpcUrl || requireEnv('RPC_URL'),
+      serverUrl: fileServerUrl || requireEnv('SERVER_URL'),
     }),
#!/bin/bash
# Verify no unsafe `as string` env fallbacks remain for PolygonModule config
rg -n "polygon: new PolygonModule|didContractAddress:|schemaManagerContractAddress:|fileServerToken:|rpcUrl:|serverUrl:" src/cliAgent.ts -C2
rg -n "process\.env\.(DID_CONTRACT_ADDRESS|SCHEMA_MANAGER_CONTRACT_ADDRESS|FILE_SERVER_TOKEN|RPC_URL|SERVER_URL)\s+as string" src/cliAgent.ts
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cliAgent.ts` around lines 240 - 249, The PolygonModule initialization
currently uses unsafe "as string" fallbacks which can hide missing env vars;
update the code that constructs new PolygonModule so each field
(didContractAddress, schemaManagerContractAddress, fileServerToken, rpcUrl,
serverUrl) first prefers the explicit parameter (e.g.,
didRegistryContractAddress, schemaManagerContractAddress, fileServerToken,
rpcUrl, fileServerUrl) and if absent reads process.env, and if the resulting
value is undefined or empty throw a clear Error (fail fast) instead of casting
with "as string"; remove all "as string" assertions and ensure the constructor
receives validated non-empty strings.
package.json (1)

42-42: ⚠️ Potential issue | 🟠 Major

Verify @ayanworks/credo-polygon-w3c-module@^2.0.0 is actually published.

If 2.x is unavailable, dependency install will fail; pin to a published version and regenerate lockfile.

#!/bin/bash
# Verify published versions and compatibility metadata from npm
npm view `@ayanworks/credo-polygon-w3c-module` versions --json
npm view `@ayanworks/credo-polygon-w3c-module`@2.0.0 version
npm view `@ayanworks/credo-polygon-w3c-module`@1.0.0 peerDependencies --json
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 42, The dependency entry
"@ayanworks/credo-polygon-w3c-module": "^2.0.0" may point to an unpublished 2.x
release; verify publication with npm view for versions and the specific 2.0.0
tag, and if 2.0.0 is not published change the package.json dependency to a
published version (e.g., pin to the latest 1.x release) replacing the "^2.0.0"
string, then regenerate the lockfile (npm install or npm ci) and commit the
updated package.json and lockfile; reference the package name
"@ayanworks/credo-polygon-w3c-module" and the version token "^2.0.0" when making
the change.
src/routes/routes.ts (1)

9-10: ⚠️ Potential issue | 🔴 Critical

Ensure Polygon controller symbol and routed methods exist and are active.

These route bindings depend on Polygon plus createKeyPair/createSchema/estimateTransaction/getSchemaById. If those are missing/commented in src/controllers/polygon/PolygonController.ts, route resolution breaks.

#!/bin/bash
# Verify Polygon controller export and required methods
sed -n '1,260p' src/controllers/polygon/PolygonController.ts
rg -n "export class Polygon|class Polygon" src/controllers/polygon/PolygonController.ts -C2
rg -nP "^\s*(public\s+)?(async\s+)?(createKeyPair|createSchema|estimateTransaction|getSchemaById)\s*\(" src/controllers/polygon/PolygonController.ts -C2
rg -n "Polygon\.prototype\.(createKeyPair|createSchema|estimateTransaction|getSchemaById)" src/routes/routes.ts

Also applies to: 1775-1920

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/routes.ts` around lines 9 - 10, The routes file imports Polygon
and expects the controller class and methods createKeyPair, createSchema,
estimateTransaction, and getSchemaById to be present and exported; inspect
src/controllers/polygon/PolygonController.ts and ensure it exports "class
Polygon" (or an exported const/class named Polygon) and that the four methods
are implemented as public (not commented out) with matching names/signatures; if
missing, re-add or uncomment these methods or export the Polygon symbol (or
adjust the routes to the actual exported name) so that references like
Polygon.prototype.createKeyPair in routes.ts resolve correctly.
src/routes/swagger.json (1)

485-488: ⚠️ Potential issue | 🟠 Major

resource still only accepts {} in AddResourceDidOperationOptions.

At Line 486, additionalProperties: false is set with no declared properties, so the required resource field (Line 498) cannot carry real payload content.

🔧 Proposed fix
"AddResourceDidOperationOptions": {
  "properties": {
    "did": {
      "type": "string"
    },
    "resource": {
-      "additionalProperties": false,
-      "type": "object"
+      "$ref": "#/components/schemas/Record_string.unknown_"
    },
    "resourceId": {
      "type": "string"
    },
#!/bin/bash
jq '.components.schemas.AddResourceDidOperationOptions.properties.resource' src/routes/swagger.json
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/swagger.json` around lines 485 - 488, The
AddResourceDidOperationOptions schema's "resource" field is currently defined as
an object with "additionalProperties": false and no declared properties, which
effectively disallows any payload; update the AddResourceDidOperationOptions ->
properties -> resource schema (the "resource" entry) to allow arbitrary object
content by either removing "additionalProperties": false or setting
"additionalProperties": true (or explicitly declaring the expected properties
for resource), so the "resource" field can carry real payloads.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/cliAgent.ts`:
- Around line 178-185: The array literals constructing the registrars and
resolvers (specifically the entries using PolygonDidRegistrar,
IndyVdrIndyDidResolver, KeyDidResolver, WebDidResolver, JwkDidResolver, and
PolygonDidResolver) are missing trailing commas which breaks the formatter;
update both arrays so each item line ends with a trailing comma (e.g., after new
PolygonDidRegistrar() and new PolygonDidResolver()) to satisfy Prettier rules
and ensure the file formats cleanly.

---

Duplicate comments:
In `@package.json`:
- Line 42: The dependency entry "@ayanworks/credo-polygon-w3c-module": "^2.0.0"
may point to an unpublished 2.x release; verify publication with npm view for
versions and the specific 2.0.0 tag, and if 2.0.0 is not published change the
package.json dependency to a published version (e.g., pin to the latest 1.x
release) replacing the "^2.0.0" string, then regenerate the lockfile (npm
install or npm ci) and commit the updated package.json and lockfile; reference
the package name "@ayanworks/credo-polygon-w3c-module" and the version token
"^2.0.0" when making the change.

In `@src/cliAgent.ts`:
- Line 68: The import for PolygonDidRegistrar, PolygonDidResolver, PolygonModule
is currently misplaced and violating import/order; move the line "import {
PolygonDidRegistrar, PolygonDidResolver, PolygonModule } from
'@ayanworks/credo-polygon-w3c-module'" into the external-imports group with the
other third-party imports (keeping a single blank line between external and
internal imports) so the external grouping order is preserved and the linter
passes.
- Around line 240-249: The PolygonModule initialization currently uses unsafe
"as string" fallbacks which can hide missing env vars; update the code that
constructs new PolygonModule so each field (didContractAddress,
schemaManagerContractAddress, fileServerToken, rpcUrl, serverUrl) first prefers
the explicit parameter (e.g., didRegistryContractAddress,
schemaManagerContractAddress, fileServerToken, rpcUrl, fileServerUrl) and if
absent reads process.env, and if the resulting value is undefined or empty throw
a clear Error (fail fast) instead of casting with "as string"; remove all "as
string" assertions and ensure the constructor receives validated non-empty
strings.

In `@src/routes/routes.ts`:
- Around line 9-10: The routes file imports Polygon and expects the controller
class and methods createKeyPair, createSchema, estimateTransaction, and
getSchemaById to be present and exported; inspect
src/controllers/polygon/PolygonController.ts and ensure it exports "class
Polygon" (or an exported const/class named Polygon) and that the four methods
are implemented as public (not commented out) with matching names/signatures; if
missing, re-add or uncomment these methods or export the Polygon symbol (or
adjust the routes to the actual exported name) so that references like
Polygon.prototype.createKeyPair in routes.ts resolve correctly.

In `@src/routes/swagger.json`:
- Around line 485-488: The AddResourceDidOperationOptions schema's "resource"
field is currently defined as an object with "additionalProperties": false and
no declared properties, which effectively disallows any payload; update the
AddResourceDidOperationOptions -> properties -> resource schema (the "resource"
entry) to allow arbitrary object content by either removing
"additionalProperties": false or setting "additionalProperties": true (or
explicitly declaring the expected properties for resource), so the "resource"
field can carry real payloads.

In `@src/utils/agent.ts`:
- Line 33: The import for PolygonModule is placed after a local import and
violates import/order; move the line importing PolygonModule from
'@ayanworks/credo-polygon-w3c-module' into the external (third-party) imports
block so it appears with other external dependencies (above any
local/project-relative imports), then re-run the linter/formatter to ensure
import/order is satisfied; reference the PolygonModule import statement to
locate and relocate it.
- Around line 130-136: PolygonModule is being instantiated with empty strings
for required config, which defers errors to runtime; update the initialization
to read the required environment/config values (didContractAddress,
schemaManagerContractAddress, fileServerToken, rpcUrl, serverUrl) and validate
them before constructing PolygonModule (e.g., throw or log fatal and exit if any
are missing/invalid) so startup fails fast; locate the PolygonModule
instantiation and replace the hardcoded empty values with the validated config
variables (and add a short helper or inline checks to surface a clear error if
any required value is absent).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9472e6c3-53ee-4113-be99-2d1b78e43b60

📥 Commits

Reviewing files that changed from the base of the PR and between 134e298 and 0f240f5.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • package.json
  • src/cliAgent.ts
  • src/routes/routes.ts
  • src/routes/swagger.json
  • src/utils/agent.ts

Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
@ajile-in
Copy link
Member

ajile-in commented Mar 6, 2026

Let’s update the README to include the prerequisite instructions for these env variables.

Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
3.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@GHkrishna
Copy link
Contributor Author

Let’s update the README to include the prerequisite instructions for these env variables.

Actually we haven't added any new variables. They were just missing from a place, where they were expected.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants