Skip to content

Feature/boe cli beta - #30

Closed
manishdex25 wants to merge 27 commits into
betafrom
feature/boe-cli-beta
Closed

Feature/boe cli beta#30
manishdex25 wants to merge 27 commits into
betafrom
feature/boe-cli-beta

Conversation

@manishdex25

@manishdex25 manishdex25 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added Obligation Registry deployment and minting commands.
    • Added BoE escrow lifecycle, transfer, return, rejection, and status commands.
    • Verification now supports BoE records, automatic network detection, and status details.
    • Improved dry-run handling and clearer contract error messages.
  • Documentation
    • Expanded the user guide with BoE workflows, verification, document extraction, wallet setup, and command references.
    • Updated supported Node.js version requirements.
  • Release Improvements
    • Added beta-channel release support and publishing configuration.

manishdex25 and others added 20 commits July 27, 2026 14:46
- Introduced new commands for managing BoE obligations, including accept, reject, transfer, and return functionalities.
- Added types for obligation registry and escrow commands to enhance type safety and clarity.
- Implemented shared utilities for prompting user inputs across obligation escrow commands.
- Enhanced transaction handling with detailed logging and error management for better user experience.
…dentialSubject fields for improved clarity and accuracy
- Updated .releaserc.json to include a new branch 'beta-boe' for beta prereleases.
- Modified release.yml to trigger workflows on pushes to the 'beta-boe' branch.
- Bumped version to 1.1.0 in package.json and package-lock.json.
- Updated @trustvc/trustvc dependency to version 2.15.0-beta.3.
- Added new dependencies including @account-abstraction/contracts and @digitalbazaar/ecdsa-rdfc-2019-cryptosuite.
- Improved README for clarity on obligation escrow commands.
…andling

- Clarified the process for minting BoE token IDs, emphasizing the need to sign with `w3c-sign` before minting.
- Improved instructions for using the Obligation Registry address in documents.
- Enhanced error messages in CLI to provide clearer guidance on contract call exceptions.
- Updated deployment logs to include instructions for using the Obligation Registry address.
- Renamed the 'beta-boe' branch to 'beta' in .releaserc.json for clarity.
- Updated CI workflow to include checks for pushes and pull requests to 'main' and 'beta' branches, as well as feature branches.
- Enhanced release workflow permissions and added npm registry URL for publishing.
- Adjusted npm publish settings in the release configuration to ensure proper deployment.
- Improved formatting for better readability, including consistent use of markdown syntax.
- Clarified instructions for using the Obligation Registry and related commands.
- Removed unnecessary whitespace to enhance overall document cleanliness.
…scrow commands

- Changed @trustvc/trustvc dependency to a local file reference for development.
- Enhanced error handling in various obligation escrow commands to ensure proper exit codes on transaction failures.
- Refactored command handlers to streamline transaction execution and error logging.
- Updated README to clarify command usage and improve overall documentation quality.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Removed redundant error checks for obligationRegistry and tokenId.
- Enhanced error message for unsupported chain IDs to provide clearer guidance on using a valid BoE document.
- Refactored command handlers for various obligation escrow actions to utilize a shared execution function, reducing code duplication.
- Improved error handling to ensure proper exit codes on transaction failures.
- Updated README to reflect changes in command usage and prerequisites for Node.js version.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Removed redundant error handling for mint transaction submission.
- Updated error handling to return null instead of throwing an error when the transaction should not proceed.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

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 Plus

Run ID: 25b2268d-c8a9-49e1-a9e7-a8d328b9b352

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

Changes

Obligation Registry and Escrow CLI

Layer / File(s) Summary
Shared command foundation
src/types.ts, src/commands/helpers.ts, src/utils/*
Adds command types, document extraction, contract validation, shared transaction handling, and contract-error decoding.
Registry commands
src/commands/obligation-registry/*, tests/commands/obligation-registry/*
Adds registry deployment and document-backed minting commands with transaction tests.
Escrow commands
src/commands/obligation-escrow/*, tests/commands/obligation-escrow/*
Adds escrow lifecycle, status, return, rejection, nomination, and transfer commands.
Verification and documentation
src/commands/verify.ts, tests/commands/verify*, README.md
Adds BoE verification and network fallback handling. Documents the new commands and workflows.
Release configuration
.github/workflows/*, .releaserc.json, package.json
Adds beta release support, npm publishing configuration, branch restrictions, and the TrustVC beta dependency.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant CLI
  participant TrustVC
  participant Blockchain
  Operator->>CLI: provide BoE document and wallet inputs
  CLI->>TrustVC: extract obligation data and prepare transaction
  TrustVC->>Blockchain: dry run and submit registry or escrow operation
  Blockchain-->>CLI: return receipt and status data
  CLI-->>Operator: display fees, result, and explorer link
Loading

Possibly related PRs

  • TrustVC/trustvc-cli#29: Contains substantially the same BoE and Obligation Registry feature set with related shared code.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the main change as a BoE CLI feature for the beta release.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/boe-cli-beta

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.

@manishdex25 manishdex25 self-assigned this Aug 3, 2026
@manishdex25
manishdex25 requested a review from rongquan1 August 3, 2026 08:31
- Removed the explicit registry URL from the release workflow.
- Cleaned up environment variable definitions for NPM token usage.

@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: 13

Caution

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

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

195-225: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

OA verification skips the --network fallback when chain lookup fails but chainId is present.

resolveFallbackProvider runs only inside if (requiresNetwork && !chainId) (lines 208-212). If chainId is present but getSupportedNetworkNameFromId/getSupportedNetwork/.provider() fails inside the try block (lines 214-221), the function falls straight to return await verifyDocument(signedVC) (line 224) without ever consulting options.network or prompting. Compare this to verifyW3CDocument (lines 174-192), which always calls resolveFallbackProvider after its own lookup attempt fails, regardless of whether chainId was present. This means a user who passes --network to rescue an OA obligation/transferable/revokable document with an unsupported embedded chain gets silently verified without a provider instead.

Additionally, when chainId is absent and resolveFallbackProvider already returns no provider (non-interactive, no --network), execution still falls into the try block with a falsy chainId, producing a second, confusing warning from the catch on top of the "non-interactive" warning already logged.

Restructure to mirror the W3C flow: attempt the chain-embedded lookup first, then always fall back to resolveFallbackProvider if that attempt didn't yield a provider.

🐛 Proposed fix to align OA fallback with the W3C flow
   // If the document is not transferable or revokable, verify directly
   if (!requiresNetwork) return await verifyDocument(signedVC);
 
-  // If chainId is not found, prefer --network / TTY prompt / no-provider fallback
-  if (requiresNetwork && !chainId) {
-    const provider = await resolveFallbackProvider(options.network);
-    if (provider) return await verifyDocument(signedVC, { provider });
-  }
-
   try {
     const chainName = getSupportedNetworkNameFromId(Number(chainId));
     const network = getSupportedNetwork(chainName);
     const provider = network.provider() as unknown as V5Provider;
     if (provider) return await verifyDocument(signedVC, { provider });
   } catch (err: unknown) {
     signale.warn(`${err instanceof Error ? err.message : String(err)}`);
   }
 
+  // Prefer --network / TTY prompt / no-provider fallback
+  const fallbackProvider = await resolveFallbackProvider(options.network);
+  if (fallbackProvider) return await verifyDocument(signedVC, { provider: fallbackProvider });
+
   // Fallback: Verify without provider
   return await verifyDocument(signedVC);
🤖 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/commands/verify.ts` around lines 195 - 225, Restructure
verifyOpenAttestationDocument so the embedded chain lookup is attempted only
when chainId is present, and resolveFallbackProvider(options.network) is always
called when that lookup does not produce a provider, including unsupported or
absent chain IDs. Return verifyDocument with the fallback provider when
available, otherwise proceed directly to the providerless verification without
re-entering the embedded lookup or emitting a duplicate warning.
🧹 Nitpick comments (10)
tests/commands/verify.obligation.test.ts (1)

118-130: 📐 Maintainability & Code Quality | 🔵 Trivial

Hardcoded enum values reduce test resilience to SDK changes.

The assertion at line 127 hardcodes status=2 terminationReason=2 instead of interpolating ObligationDocumentStatus.Rejected and ObligationEscrowTerminationReason.Rejected, which are already imported and used elsewhere in this file (lines 60-61). If the SDK changes these numeric values, this assertion silently passes or fails without reflecting the actual enum semantics being tested.

♻️ Proposed fix to reference the enum members directly
       expect(signale.default.info).toHaveBeenCalledWith(
-        'Obligation document status: registry=0xRegistry status=2 terminationReason=2',
+        `Obligation document status: registry=0xRegistry status=${ObligationDocumentStatus.Rejected} terminationReason=${ObligationEscrowTerminationReason.Rejected}`,
       );
🤖 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 `@tests/commands/verify.obligation.test.ts` around lines 118 - 130, Update the
obligation status assertion in the shredded BoE test within describe('verify')
to interpolate ObligationDocumentStatus.Rejected and
ObligationEscrowTerminationReason.Rejected instead of hardcoded numeric values,
reusing the existing imports while preserving the expected log message
structure.
tests/utils/contract-errors.test.ts (1)

57-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for single-word non-revert reasons.

The current negative tests use multi-word text only. A single-word reason such as timeout currently passes normalizeLabel and is reported as a contract revert. See the related comment on src/utils/cli-errors.ts lines 100-111. Add the case so the fix stays covered.

💚 Proposed test
   it('rejects generic failed: suffixes that are not contract reverts', () => {
     const preprocessing = new Error('SDK preprocessing failed: badInput');
     expect(extractContractRevertLabel(preprocessing)).toBeUndefined();
     expect(isContractCallException(preprocessing)).toBe(false);
   });
+
+  it('does not treat single-word transient reasons as contract reverts', () => {
+    const transient = Object.assign(new Error('timeout'), { reason: 'timeout' });
+    expect(extractContractRevertLabel(transient)).toBeUndefined();
+    expect(isContractCallException(transient)).toBe(false);
+  });
🤖 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 `@tests/utils/contract-errors.test.ts` around lines 57 - 76, Add a regression
case in the contract-error tests covering a single-word non-revert reason such
as “timeout”; assert extractContractRevertLabel returns undefined and the error
is not classified as a contract call exception, matching the existing multi-word
negative cases.
src/commands/helpers.ts (1)

470-507: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse connectToObligationRegistry inside connectToObligationEscrow.

connectToObligationEscrow builds its own registry contract instance. src/commands/obligation-escrow/runTx.ts (lines 47-55) then calls connectToObligationRegistry for the same address, so the registry contract is constructed twice per transaction. Calling the existing helper removes the duplicate construction and gives the escrow path the same registry bytecode validation.

♻️ Proposed refactor
   try {
-    signale.info(`Connecting to obligation registry at: ${address}`);
-    const registry = new ethers.Contract(address, TrustVCToken__factory.abi, wallet as any);
+    const registry = await connectToObligationRegistry({ address, wallet });
 
     signale.info(`Fetching obligation escrow address for tokenId: ${tokenId}`);
🤖 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/commands/helpers.ts` around lines 470 - 507, Update
connectToObligationEscrow to obtain the registry through the existing
connectToObligationRegistry helper instead of constructing a new ethers.Contract
directly. Preserve the existing ownerOf lookup and escrow validation flow,
passing the address and wallet required by the helper so registry bytecode
validation and construction are reused.
tests/commands/obligation-registry/mint.test.ts (1)

64-93: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add direct unit tests for extractObligationDocumentInfo.

This suite mocks extractObligationDocumentInfo, so the extractor in src/utils/obligation-document.ts is never executed. The extractor drives the registry address, the token ID, the network, and the remark encryption key for every registry and escrow command. No test file for it appears in this cohort. Add cases for the non-obligation document rejection, the unsupported chain ID, and the missing document.id path.
Do you want me to generate the test file?

🤖 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 `@tests/commands/obligation-registry/mint.test.ts` around lines 64 - 93, Add a
dedicated unit-test suite for extractObligationDocumentInfo in
src/utils/obligation-document.ts instead of relying on the mocked extractor in
mint.test.ts. Cover rejection of non-obligation documents, unsupported chain
IDs, and documents missing document.id, while asserting the expected errors or
failure behavior for each case.
src/commands/obligation-registry/deploy.ts (2)

112-112: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Resolve the chain ID through one helper.

Line 112 indexes supportedNetwork directly, and line 151 calls getSupportedNetwork(network) for the same value. If network is not a key of supportedNetwork, line 112 throws a TypeError on .networkId. chainId is used only for the log at line 165. Use getSupportedNetwork in both places.

♻️ Proposed refactor
-    const chainId = supportedNetwork[network as NetworkCmdName].networkId;
+    const chainId = getSupportedNetwork(network).networkId;
🤖 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/commands/obligation-registry/deploy.ts` at line 112, Update the chainId
initialization in the deploy flow to use getSupportedNetwork(network), matching
the existing lookup near the later deployment logic instead of indexing
supportedNetwork directly. Preserve the chain ID used by the log while ensuring
unsupported network names are handled consistently through the helper.

30-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Handler catch blocks bypass getErrorMessage. Both command handlers print err.message directly. This PR adds contract-revert decoding in getErrorMessage, so these two paths report raw ethers text such as execution reverted (unknown custom error) instead of the actionable message. getErrorMessage is already imported in both files.

  • src/commands/obligation-registry/deploy.ts#L30-L33: replace error(err instanceof Error ? err.message : String(err)) with error(getErrorMessage(err)).
  • src/commands/obligation-registry/mint.ts#L34-L37: apply the same replacement.
🤖 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/commands/obligation-registry/deploy.ts` around lines 30 - 33, Update the
catch handler in src/commands/obligation-registry/deploy.ts lines 30-33 to pass
the caught error to the existing getErrorMessage helper before calling error.
Apply the same change in src/commands/obligation-registry/mint.ts lines 34-37,
replacing the direct err.message/String formatting while preserving the existing
exit-code behavior.
tests/commands/obligation-registry/deploy.test.ts (1)

94-125: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add coverage for the dry-run branches.

The suite only covers the success path with no factory address. Two behaviors added in this PR remain untested: the skip of the dry run when escrowFactoryAddress is absent, and the null result that must set process.exitCode = 1 and return null. Add cases for both.

🤖 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 `@tests/commands/obligation-registry/deploy.test.ts` around lines 94 - 125,
Extend the deployObligationRegistryContract tests with cases covering both
dry-run branches: verify the dry run is skipped when escrowFactoryAddress is
absent, and verify a null dry-run result sets process.exitCode to 1 and returns
null. Reuse the existing SDK and logging mocks, and assert the relevant dry-run
invocation and exit-code behavior.
src/commands/obligation-escrow/reject-transfer-owner-holder.ts (1)

21-39: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Two escrow handlers skip the cohort's try/catch error-handling pattern.

rejectTransferOwnersHandler and transferOwnersHandler don't wrap their body in try/catch or log via getErrorMessage, unlike acceptReturnedHandler, endorseHandler, and changeHolderHandler in the same cohort. The outer runObligationEscrowCommand wrapper still catches unhandled errors in the production handler path (per src/commands/obligation-escrow/shared.ts), so this is not a functional break today. It is an inconsistency that risks diverging further as more escrow commands are added, and it means calling these handlers directly (as the corresponding test files do) bypasses error handling entirely.

  • src/commands/obligation-escrow/reject-transfer-owner-holder.ts#L21-L39: wrap the handler body in try/catch, log with error(getErrorMessage(e)), and set process.exitCode = 1 on failure, matching sibling handlers.
  • src/commands/obligation-escrow/transfer-owner-holder.ts#L28-L54: apply the same try/catch pattern.
🤖 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/commands/obligation-escrow/reject-transfer-owner-holder.ts` around lines
21 - 39, Update rejectTransferOwnersHandler in
src/commands/obligation-escrow/reject-transfer-owner-holder.ts (lines 21-39) and
transferOwnersHandler in src/commands/obligation-escrow/transfer-owner-holder.ts
(lines 28-54) to wrap their existing logic in try/catch; on failure, log
getErrorMessage(e) via error and set process.exitCode = 1, matching the sibling
escrow handlers.
src/types.ts (1)

125-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Escrow command type names don't match the commands that use them.

ObligationEscrowEndorseTransferOfOwnersCommand (defined with newHolder/newOwner) sounds like it belongs to an "endorse transfer owner" command, but transfer-owner-holder.ts consumes it. ObligationEscrowNominateBeneficiaryCommand (defined with newBeneficiary only) sounds "nominate"-specific, but endorse-transfer-owner.ts consumes it instead. Both types are structurally correct for their handlers today, so this does not break functionality. It does create confusion for anyone reading the command-to-type mapping, and increases the risk of a future contributor picking the wrong type when adding or modifying an escrow command.

  • src/types.ts#L125-L137: rename ObligationEscrowEndorseTransferOfOwnersCommand and ObligationEscrowNominateBeneficiaryCommand to names that reflect their actual field shape rather than a specific command (for example ObligationEscrowTransferOwnersCommand for the newHolder+newOwner shape, and ObligationEscrowNewBeneficiaryCommand for the newBeneficiary-only shape, shared by both nominate and endorse commands).
  • src/commands/obligation-escrow/endorse-transfer-owner.ts#L1-L25: update the import and type annotations to the renamed type.
  • src/commands/obligation-escrow/transfer-owner-holder.ts#L1-L26: update the import and type annotations to the renamed type.
🤖 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/types.ts` around lines 125 - 137, Rename the two escrow command types in
src/types.ts#L125-L137 to reflect their field shapes: use a shared
transfer-owners name for the newHolder/newOwner shape and a new-beneficiary name
for the newBeneficiary-only shape. Update imports and type annotations in
src/commands/obligation-escrow/endorse-transfer-owner.ts#L1-L25 and
src/commands/obligation-escrow/transfer-owner-holder.ts#L1-L26 to reference the
renamed types, preserving their existing structural usage.
tests/commands/obligation-escrow/return-to-issuer.test.ts (1)

54-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align test coverage with sibling test files.

This test only asserts runObligationEscrowTx was called, without checking the populate/sdkParams arguments. Sibling tests (reject.test.ts, reject-transfer-owner.test.ts) assert on sdkParams, and other sibling tests also cover promptForInputs. Add an equivalent promptForInputs test and an sdkParams/populate assertion here for parity.

🤖 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 `@tests/commands/obligation-escrow/return-to-issuer.test.ts` around lines 54 -
68, The returnToIssuerHandler tests should match sibling coverage by adding a
promptForInputs behavior test and expanding the runObligationEscrowTx assertion
to verify the expected populate/sdkParams arguments. Use the existing test
patterns and mocks from reject.test.ts and reject-transfer-owner.test.ts,
updating the return-to-issuer suite without changing production code.
🤖 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 `@package.json`:
- Line 38: Update the `@trustvc/trustvc` dependency in package.json from the beta
version to a stable TrustVC release before the first main release, or configure
the dependency separately for beta and main branches so the stable
semantic-release path cannot include the beta SDK.

In `@README.md`:
- Around line 1669-1686: Correct the README project tree entry for verify.ts to
reference src/commands/verify.ts rather than src/commands/w3c/. Keep verify.ts
as a direct child of src/commands and adjust the surrounding tree branch
characters to match the corrected hierarchy.
- Around line 345-351: Update the Obligation/BoE command table in README.md so
every command row links to its corresponding detailed heading below, including
the grouped reject-transfer-* row linking to the shared transfer section.
Preserve the existing command names and descriptions while adding links
consistently with the README’s established anchor format.
- Around line 1409-1560: Update the README documentation for obligation-escrow
accept-return-to-issuer and reject-return-to-issuer to state that the connected
issuer wallet must have the required obligation registry role: accepter for
burn/shred and restorer for restoring the BoE to escrow. Keep the existing
wallet/private-key prompt documentation unchanged.

In `@src/commands/obligation-escrow/index.ts`:
- Around line 8-9: Update the builder function’s commandDir configuration to
load only valid command modules, excluding helper files such as runTx.ts and
shared.ts while retaining the intended obligation-escrow subcommands.

In `@src/commands/obligation-escrow/nominate-transfer-owner.ts`:
- Around line 26-44: Wrap the transaction flow in nominateHandler with
try/catch, including the initial logging and runObligationEscrowTx call.
Preserve the existing success and early-return behavior, and mirror
acceptHandler’s catch path by formatting/logging the failure and setting
process.exitCode to 1.

In `@src/commands/obligation-escrow/reject-transfer-holder.ts`:
- Around line 21-39: Wrap the transaction execution flow in
rejectTransferHolderHandler with the same try/catch error handling used by
acceptHandler and nominateHandler. Handle errors from runObligationEscrowTx and
the subsequent transaction reporting consistently with those handlers, while
preserving the existing success and early-return behavior.

In `@src/commands/obligation-escrow/shared.ts`:
- Around line 48-60: Remove the redundant local try/catch blocks from
dischargeHandler in src/commands/obligation-escrow/discharge.ts#L23-L46,
rejectReturnedHandler in
src/commands/obligation-escrow/reject-return-to-issuer.ts#L22-L46,
rejectTransferOwnerHandler in
src/commands/obligation-escrow/reject-transfer-owner.ts#L22-L45, rejectHandler
in src/commands/obligation-escrow/reject.ts#L22-L44, and returnToIssuerHandler
in src/commands/obligation-escrow/return-to-issuer.ts#L22-L45, allowing errors
to propagate to runObligationEscrowCommand. Keep
src/commands/obligation-escrow/shared.ts#L48-L60 unchanged as the sole shared
error handler.
- Around line 15-42: Update promptBaseObligationEscrowInputs to catch
cancellation rejections from promptAndReadDocument and promptWalletSelection,
returning the falsy result expected by runObligationEscrowCommand instead of
propagating the error. Preserve the existing successful prompt flow and input
construction, while allowing non-cancellation errors to retain their current
handling.

In `@src/commands/verify.ts`:
- Around line 136-152: Validate networkOverride in resolveFallbackProvider
before calling getSupportedNetwork, ensuring it matches a supportedNetwork key;
when invalid, throw an actionable error that identifies the bad network and
explains how to select a valid one. Preserve the existing provider resolution
for valid overrides and the interactive/non-interactive fallback behavior.

In `@src/utils/cli-errors.ts`:
- Around line 100-111: Update normalizeLabel to accept only PascalCase Solidity
custom-error identifiers, reusing the existing SOLIDITY_CUSTOM_ERROR_NAME
pattern rather than the current broad identifier regex. Preserve trimming and
rejection of unknown labels, while ensuring lowercase or otherwise
non-PascalCase single-word reasons return undefined.

In `@src/utils/cli-options.ts`:
- Around line 538-547: Update callers of performDryRunWithConfirmation,
including the document-store and token-registry deploy/issue/mint commands, to
check shouldProceed === null before the existing cancellation branch and exit
with failure status for definitive dry-run reverts. Preserve process.exit(0) for
user cancellation, and keep successful execution unchanged.

In `@src/utils/obligation-document.ts`:
- Line 58: Remove the `'N/A'` fallback from documentId in the obligation
document creation flow. Validate that document.id is present and throw an error
when it is missing; otherwise return the actual document.id so downstream
encryptionKey consumers and SDK options never use a shared placeholder key.

---

Outside diff comments:
In `@src/commands/verify.ts`:
- Around line 195-225: Restructure verifyOpenAttestationDocument so the embedded
chain lookup is attempted only when chainId is present, and
resolveFallbackProvider(options.network) is always called when that lookup does
not produce a provider, including unsupported or absent chain IDs. Return
verifyDocument with the fallback provider when available, otherwise proceed
directly to the providerless verification without re-entering the embedded
lookup or emitting a duplicate warning.

---

Nitpick comments:
In `@src/commands/helpers.ts`:
- Around line 470-507: Update connectToObligationEscrow to obtain the registry
through the existing connectToObligationRegistry helper instead of constructing
a new ethers.Contract directly. Preserve the existing ownerOf lookup and escrow
validation flow, passing the address and wallet required by the helper so
registry bytecode validation and construction are reused.

In `@src/commands/obligation-escrow/reject-transfer-owner-holder.ts`:
- Around line 21-39: Update rejectTransferOwnersHandler in
src/commands/obligation-escrow/reject-transfer-owner-holder.ts (lines 21-39) and
transferOwnersHandler in src/commands/obligation-escrow/transfer-owner-holder.ts
(lines 28-54) to wrap their existing logic in try/catch; on failure, log
getErrorMessage(e) via error and set process.exitCode = 1, matching the sibling
escrow handlers.

In `@src/commands/obligation-registry/deploy.ts`:
- Line 112: Update the chainId initialization in the deploy flow to use
getSupportedNetwork(network), matching the existing lookup near the later
deployment logic instead of indexing supportedNetwork directly. Preserve the
chain ID used by the log while ensuring unsupported network names are handled
consistently through the helper.
- Around line 30-33: Update the catch handler in
src/commands/obligation-registry/deploy.ts lines 30-33 to pass the caught error
to the existing getErrorMessage helper before calling error. Apply the same
change in src/commands/obligation-registry/mint.ts lines 34-37, replacing the
direct err.message/String formatting while preserving the existing exit-code
behavior.

In `@src/types.ts`:
- Around line 125-137: Rename the two escrow command types in
src/types.ts#L125-L137 to reflect their field shapes: use a shared
transfer-owners name for the newHolder/newOwner shape and a new-beneficiary name
for the newBeneficiary-only shape. Update imports and type annotations in
src/commands/obligation-escrow/endorse-transfer-owner.ts#L1-L25 and
src/commands/obligation-escrow/transfer-owner-holder.ts#L1-L26 to reference the
renamed types, preserving their existing structural usage.

In `@tests/commands/obligation-escrow/return-to-issuer.test.ts`:
- Around line 54-68: The returnToIssuerHandler tests should match sibling
coverage by adding a promptForInputs behavior test and expanding the
runObligationEscrowTx assertion to verify the expected populate/sdkParams
arguments. Use the existing test patterns and mocks from reject.test.ts and
reject-transfer-owner.test.ts, updating the return-to-issuer suite without
changing production code.

In `@tests/commands/obligation-registry/deploy.test.ts`:
- Around line 94-125: Extend the deployObligationRegistryContract tests with
cases covering both dry-run branches: verify the dry run is skipped when
escrowFactoryAddress is absent, and verify a null dry-run result sets
process.exitCode to 1 and returns null. Reuse the existing SDK and logging
mocks, and assert the relevant dry-run invocation and exit-code behavior.

In `@tests/commands/obligation-registry/mint.test.ts`:
- Around line 64-93: Add a dedicated unit-test suite for
extractObligationDocumentInfo in src/utils/obligation-document.ts instead of
relying on the mocked extractor in mint.test.ts. Cover rejection of
non-obligation documents, unsupported chain IDs, and documents missing
document.id, while asserting the expected errors or failure behavior for each
case.

In `@tests/commands/verify.obligation.test.ts`:
- Around line 118-130: Update the obligation status assertion in the shredded
BoE test within describe('verify') to interpolate
ObligationDocumentStatus.Rejected and ObligationEscrowTerminationReason.Rejected
instead of hardcoded numeric values, reusing the existing imports while
preserving the expected log message structure.

In `@tests/utils/contract-errors.test.ts`:
- Around line 57-76: Add a regression case in the contract-error tests covering
a single-word non-revert reason such as “timeout”; assert
extractContractRevertLabel returns undefined and the error is not classified as
a contract call exception, matching the existing multi-word negative 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 Plus

Run ID: 5e16ace7-b22d-4630-a022-6a46761b52db

📥 Commits

Reviewing files that changed from the base of the PR and between ea07583 and 8a81dc1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (53)
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • .releaserc.json
  • README.md
  • package.json
  • src/commands/helpers.ts
  • src/commands/obligation-escrow/accept-return-to-issuer.ts
  • src/commands/obligation-escrow/accept.ts
  • src/commands/obligation-escrow/discharge.ts
  • src/commands/obligation-escrow/endorse-transfer-owner.ts
  • src/commands/obligation-escrow/index.ts
  • src/commands/obligation-escrow/nominate-transfer-owner.ts
  • src/commands/obligation-escrow/reject-return-to-issuer.ts
  • src/commands/obligation-escrow/reject-transfer-holder.ts
  • src/commands/obligation-escrow/reject-transfer-owner-holder.ts
  • src/commands/obligation-escrow/reject-transfer-owner.ts
  • src/commands/obligation-escrow/reject.ts
  • src/commands/obligation-escrow/return-to-issuer.ts
  • src/commands/obligation-escrow/runTx.ts
  • src/commands/obligation-escrow/shared.ts
  • src/commands/obligation-escrow/status.ts
  • src/commands/obligation-escrow/transfer-holder.ts
  • src/commands/obligation-escrow/transfer-owner-holder.ts
  • src/commands/obligation-registry/deploy.ts
  • src/commands/obligation-registry/index.ts
  • src/commands/obligation-registry/mint.ts
  • src/commands/verify.ts
  • src/types.ts
  • src/utils/cli-errors.ts
  • src/utils/cli-options.ts
  • src/utils/formatting.ts
  • src/utils/index.ts
  • src/utils/obligation-document.ts
  • tests/commands/obligation-escrow/accept-return-to-issuer.test.ts
  • tests/commands/obligation-escrow/accept.test.ts
  • tests/commands/obligation-escrow/discharge.test.ts
  • tests/commands/obligation-escrow/endorse-transfer-owner.test.ts
  • tests/commands/obligation-escrow/nominate-transfer-owner.test.ts
  • tests/commands/obligation-escrow/reject-return-to-issuer.test.ts
  • tests/commands/obligation-escrow/reject-transfer-holder.test.ts
  • tests/commands/obligation-escrow/reject-transfer-owner-holder.test.ts
  • tests/commands/obligation-escrow/reject-transfer-owner.test.ts
  • tests/commands/obligation-escrow/reject.test.ts
  • tests/commands/obligation-escrow/return-to-issuer.test.ts
  • tests/commands/obligation-escrow/status.test.ts
  • tests/commands/obligation-escrow/transfer-holder.test.ts
  • tests/commands/obligation-escrow/transfer-owner-holder.test.ts
  • tests/commands/obligation-registry/deploy.test.ts
  • tests/commands/obligation-registry/mint.test.ts
  • tests/commands/verify.obligation.test.ts
  • tests/commands/verify.test.ts
  • tests/fixtures/obligation/w3c-obligation-record.json
  • tests/utils/contract-errors.test.ts

Comment thread package.json
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md
Comment thread src/commands/obligation-escrow/index.ts Outdated
Comment thread src/commands/obligation-escrow/shared.ts
Comment thread src/commands/verify.ts
Comment thread src/utils/cli-errors.ts Outdated
Comment thread src/utils/cli-options.ts Outdated
Comment thread src/utils/obligation-document.ts Outdated
…andling in command files

- Introduced a new JSON file for the driving licence credential schema.
- Improved error handling in various command files to ensure proper exit codes on transaction failures.
- Updated README for better command usage clarity.
- Updated input prompts in various obligation escrow command files to return null on cancellation, improving user experience.
- Enhanced error handling in command handlers to ensure proper exit codes on transaction failures.
- Clarified roles and responsibilities in the README for executing commands related to obligation escrow.
- Added checks to ensure proper exit codes when `shouldProceed` is null in various document store and title escrow command files.
- Updated README to reflect the new structure of command files for better clarity.

@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: 2

🤖 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 `@decrypted.json`:
- Line 1: Update the decrypted credential fixture used by verification to
represent a signed or wrapped credential: generate it through the
signing/wrapping pipeline so it contains the expected W3C proof or
OpenAttestation data/signature shape. Alternatively, if this fixture
intentionally remains plaintext, change the related verification assertion to
expect verifyDocumentSignature() to fail.

In `@README.md`:
- Line 1693: Update the verify.ts project-tree entry to describe verification of
W3C, OA, ETR, and BoE documents, matching the unified trustvc verify behavior
documented above.
🪄 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 Plus

Run ID: 8ce3d8ef-1bf9-44aa-986a-a7af527e8cdc

📥 Commits

Reviewing files that changed from the base of the PR and between 8a81dc1 and 82684c6.

📒 Files selected for processing (36)
  • .github/workflows/release.yml
  • README.md
  • decrypted.json
  • src/commands/document-store/deploy.ts
  • src/commands/document-store/grant-role.ts
  • src/commands/document-store/issue.ts
  • src/commands/document-store/revoke-role.ts
  • src/commands/document-store/revoke.ts
  • src/commands/obligation-escrow/discharge.ts
  • src/commands/obligation-escrow/endorse-transfer-owner.ts
  • src/commands/obligation-escrow/index.ts
  • src/commands/obligation-escrow/nominate-transfer-owner.ts
  • src/commands/obligation-escrow/reject-return-to-issuer.ts
  • src/commands/obligation-escrow/reject-transfer-holder.ts
  • src/commands/obligation-escrow/reject-transfer-owner.ts
  • src/commands/obligation-escrow/reject.ts
  • src/commands/obligation-escrow/return-to-issuer.ts
  • src/commands/obligation-escrow/shared.ts
  • src/commands/obligation-escrow/transfer-holder.ts
  • src/commands/obligation-escrow/transfer-owner-holder.ts
  • src/commands/title-escrow/accept-return-to-issuer.ts
  • src/commands/title-escrow/endorse-transfer-owner.ts
  • src/commands/title-escrow/nominate-transfer-owner.ts
  • src/commands/title-escrow/reject-return-to-issuer.ts
  • src/commands/title-escrow/reject-transfer-holder.ts
  • src/commands/title-escrow/reject-transfer-owner-holder.ts
  • src/commands/title-escrow/reject-transfer-owner.ts
  • src/commands/title-escrow/return-to-issuer.ts
  • src/commands/title-escrow/transfer-holder.ts
  • src/commands/title-escrow/transfer-owner-holder.ts
  • src/commands/token-registry/deploy.ts
  • src/commands/token-registry/mint.ts
  • src/commands/verify.ts
  • src/utils/cli-errors.ts
  • src/utils/obligation-document.ts
  • tests/utils/contract-errors.test.ts
💤 Files with no reviewable changes (1)
  • .github/workflows/release.yml
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/commands/obligation-escrow/reject-return-to-issuer.ts
  • src/commands/obligation-escrow/index.ts
  • src/utils/obligation-document.ts
  • tests/utils/contract-errors.test.ts
  • src/commands/obligation-escrow/return-to-issuer.ts
  • src/utils/cli-errors.ts
  • src/commands/obligation-escrow/nominate-transfer-owner.ts
  • src/commands/obligation-escrow/reject.ts
  • src/commands/obligation-escrow/endorse-transfer-owner.ts
  • src/commands/verify.ts

Comment thread decrypted.json Outdated
Comment thread README.md Outdated
- Added decrypted.json to .gitignore to prevent tracking of sensitive files.
- Removed the decrypted.json file as it is no longer needed.
- Updated README to clarify command usage and improve overall documentation structure.
- Removed redundant checks for `shouldProceed` being null in various command files to streamline exit logic.
- Updated README to reflect changes in command verification processes for improved clarity.
- Simplified CLI error helpers by removing outdated constants and functions related to known revert messages and selectors.
- Updated comments for clarity and conciseness, enhancing the overall readability of the error handling logic.
@manishdex25 manishdex25 closed this Aug 3, 2026
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.

1 participant