Skip to content

feat: implement obligation registry functions and enhance document bu… - #155

Merged
rongquan1 merged 40 commits into
betafrom
feature/boe-v2
Jul 31, 2026
Merged

feat: implement obligation registry functions and enhance document bu…#155
rongquan1 merged 40 commits into
betafrom
feature/boe-v2

Conversation

@manishdex25

@manishdex25 manishdex25 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

…ilder

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

  • New Features

    • Added Obligation Registry and Bill of Exchange support, including deployment, minting, lifecycle, transfers, escrow, and endorsement-chain utilities.
    • Added obligation-record credential status configuration and on-chain verification.
    • Added obligation lifecycle events and enhanced endorsement-chain retrieval.
    • Expanded Document Builder and package exports with obligation-record functionality.
  • Bug Fixes

    • Corrected owner and beneficiary handling during obligation transfers.
    • Improved verification outcomes for unissued or terminated obligations.
  • Documentation

    • Expanded guidance for Obligation Registry, BoE workflows, verification, and Document Builder usage.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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: 77bfb5db-e04e-4be6-aba9-de943068d821

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

Adds Obligation Registry APIs, BoE credential-status verification and DocumentBuilder support, shared escrow utilities, ethers v5/v6 tests, E2E fixtures, package exports, endorsement-chain support, and updated BoE documentation.

Changes

Obligation Registry API and contracts

Layer / File(s) Summary
Registry types, deployment, and transaction operations
src/obligation-registry-functions/*, src/token-registry-v5/contracts.ts, package.json
Adds typed deployment, minting, lifecycle, transfer, return-token, owner, status, escrow, and endorsement-chain helpers with ethers v5/v6 support and public package exports.
Shared execution flow
src/obligation-registry-functions/utils.ts, src/obligation-registry-functions/{mint,lifecycle,transfer,returnToken,status}.ts
Centralizes escrow resolution, encrypted remarks, static pre-checks, interface validation, and transaction submission.

BoE document verification and signing

Layer / File(s) Summary
Credential-status classification and builder integration
src/core/documentBuilder.ts, src/utils/documents/*
Adds obligationRecords configuration, registry interface validation, obligation-record type guards, and document helpers.
Obligation-record verification
src/verify/fragments/document-status/obligationRecords/*, src/verify/fragments/document-status/transferableRecords/*, src/verify/*
Adds typed VALID/INVALID/SKIPPED/ERROR fragments, on-chain ownership and escrow checks, and registration in the W3C verifier set.

Validation and documentation

Layer / File(s) Summary
Unit and E2E validation
src/__tests__/obligation-registry-functions/*, src/__tests__/e2e/*, src/__tests__/verify/*
Tests deployment, lifecycle transitions, status reads, transfers, returned-token flows, verification outcomes, validation failures, and both ethers versions.
BoE usage and test configuration
README.md, .github/workflows/tests.yml, src/__tests__/core/*
Documents verification routing, skipped fragments, Obligation Registry lifecycle outcomes, builder configuration, imports, minting requirements, and configurable Polygon Amoy RPC connectivity.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: released on @v1``

Suggested reviewers: rongquan1, nghaninn, rishabhs7

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the required headings but contains only template prompts and no project-specific details. Replace the placeholder prompts with the PR background, a concrete change list, and related issue or story references.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main changes: obligation registry functions and document builder enhancements.
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-v2

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.

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

🧹 Nitpick comments (2)
src/obligation-registry-functions/deploy.ts (1)

2-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Merge duplicate import from the same module.

SonarCloud flags '../token-registry-functions/utils' imported twice.

♻️ Proposed fix
-import { getTxOptions } from '../token-registry-functions/utils';
-import { getChainIdSafe } from '../token-registry-functions/utils';
+import { getTxOptions, getChainIdSafe } from '../token-registry-functions/utils';
🤖 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/obligation-registry-functions/deploy.ts` around lines 2 - 3, Combine the
duplicate imports from '../token-registry-functions/utils' into a single import
declaration containing both getTxOptions and getChainIdSafe.

Source: Linters/SAST tools

src/__tests__/e2e/utils.ts (1)

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

Consider consolidating with getVersionedContractFactory/createContract to avoid duplicated ethers-version branching.

getObligationContractFactory and createObligationContract re-implement the same v5/v6 factory/contract-selection logic as getVersionedContractFactory (Line 6) and createContract (Line 24), just with a fixed contract source (v5Contracts). Parameterizing the existing helpers by contract-source instead of adding parallel obligation-specific variants would reduce the number of places that need updating if ethers-version handling changes.

♻️ Sketch of a consolidated helper
-export function getObligationContractFactory(
-  contractName: 'TrustVCToken' | 'ObligationEscrowFactory',
-  ethersVersion: 'v5' | 'v6',
-  owner: Signer | ContractRunner,
-) {
-  const Factory = ethersVersion === 'v5' ? ethers.ContractFactory : ethersV6.ContractFactory;
-  const signer = ethersVersion === 'v5' ? (owner as Signer) : (owner as ContractRunner);
-
-  return new Factory(
-    v5Contracts[`${contractName}__factory`].abi,
-    v5Contracts[`${contractName}__factory`].bytecode,
-    // eslint-disable-next-line `@typescript-eslint/no-explicit-any`
-    signer as any,
-  );
-}
+export function getObligationContractFactory(
+  contractName: 'TrustVCToken' | 'ObligationEscrowFactory',
+  ethersVersion: 'v5' | 'v6',
+  owner: Signer | ContractRunner,
+) {
+  return getVersionedContractFactory(contractName as any, ethersVersion, 'v5', owner);
+}
🤖 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__/e2e/utils.ts` around lines 40 - 68, Consolidate
getObligationContractFactory and createObligationContract with the existing
getVersionedContractFactory and createContract helpers by parameterizing those
helpers to accept the fixed v5Contracts source. Update obligation callers to use
the shared helpers, preserve the existing contract names, ABIs, bytecode, and
signer behavior, and remove the duplicated ethers-version branching.
🤖 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 `@README.md`:
- Line 774: Update the fenced lifecycle diagram code block in README.md to
specify the text language by changing its opening fence to use text, while
preserving the diagram content and closing fence.

In `@src/__tests__/e2e/obligation-registry-functions/transfer.e2e.test.ts`:
- Around line 76-84: In the transferHolderObligationRegistry rejection
assertions, replace the unavailable rejectedWith matcher with the Hardhat
revertedWith matcher at all three referenced assertions, preserving the existing
expected error message patterns.

In `@src/obligation-registry-functions/mint.ts`:
- Around line 39-52: Replace the duplicated encryption and static-call logic in
src/obligation-registry-functions/mint.ts lines 39-52 with
getEncryptedRemarks(remarks, options.id) and runStaticCall for mint using
signer.provider; apply the same change in
src/obligation-registry-functions/returnToken.ts lines 68-81 for
acceptReturnedObligationRegistry using burn, and lines 113-126 for
rejectReturnedObligationRegistry using restore, preserving the shared helper
behavior across all three sites.

In `@src/obligation-registry-functions/ownerOf.ts`:
- Around line 16-19: In the ownerOf function, replace the unused options
parameter with the module’s underscore-prefixed convention (for example,
_options), remove the void options statement, and preserve the existing API
signature and behavior.

In `@src/obligation-registry-functions/status.ts`:
- Around line 12-54: Clarify the token ID behavior in
getObligationRegistryStatus, isObligationRegistryRegistered, and
getObligationEscrowTerminationReason by documenting that _params.tokenId is
unused and contractOptions.tokenId is the authoritative value for escrow
resolution. Keep the existing function signatures and logic unchanged.

In `@src/obligation-registry-functions/utils.ts`:
- Around line 73-78: Update getEncryptedRemarks so supplied remarks are not
discarded when id is undefined; preserve the existing encrypted 0x-prefixed
result when both remarks and id are present, and define a non-lossy fallback for
remarks without an id instead of returning only '0x'.
- Around line 33-50: Update the tokenId validation in the obligation escrow
resolution path around getObligationEscrowAddress to accept numeric 0 while
rejecting missing or empty token IDs. Replace the truthiness check with explicit
undefined and empty-value handling, preserving validation for genuinely absent
values and the existing resolution flow.

In `@src/verify/fragments/document-status/obligationRecords/utils.ts`:
- Around line 73-90: Update the catch handling around the canonical ownerOf call
to return DOCUMENT_NOT_MINTED only for its expected revert error; rethrow all
other Ethers/provider, network, and address failures so the verifier wrapper
produces ERROR. Preserve the existing CodedError propagation and minted:false
response for the canonical revert.

---

Nitpick comments:
In `@src/__tests__/e2e/utils.ts`:
- Around line 40-68: Consolidate getObligationContractFactory and
createObligationContract with the existing getVersionedContractFactory and
createContract helpers by parameterizing those helpers to accept the fixed
v5Contracts source. Update obligation callers to use the shared helpers,
preserve the existing contract names, ABIs, bytecode, and signer behavior, and
remove the duplicated ethers-version branching.

In `@src/obligation-registry-functions/deploy.ts`:
- Around line 2-3: Combine the duplicate imports from
'../token-registry-functions/utils' into a single import declaration containing
both getTxOptions and getChainIdSafe.
🪄 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: 973dedb2-292e-48c0-b49b-2c1b74a60dac

📥 Commits

Reviewing files that changed from the base of the PR and between 7598cd1 and b63ca01.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (39)
  • README.md
  • package.json
  • src/__tests__/e2e/fixtures/sample-boe-credential.ts
  • src/__tests__/e2e/obligation-registry-functions/fixtures.ts
  • src/__tests__/e2e/obligation-registry-functions/statusLifecycle.e2e.test.ts
  • src/__tests__/e2e/obligation-registry-functions/transfer.e2e.test.ts
  • src/__tests__/e2e/utils.ts
  • src/__tests__/obligation-registry-functions/deploy.test.ts
  • src/__tests__/obligation-registry-functions/fixtures.ts
  • src/__tests__/obligation-registry-functions/lifecycle.test.ts
  • src/__tests__/obligation-registry-functions/mint.test.ts
  • src/__tests__/obligation-registry-functions/ownerOf.test.ts
  • src/__tests__/obligation-registry-functions/rejectTransfers.test.ts
  • src/__tests__/obligation-registry-functions/returnToken.test.ts
  • src/__tests__/obligation-registry-functions/status.test.ts
  • src/__tests__/obligation-registry-functions/transfers.test.ts
  • src/core/documentBuilder.ts
  • src/core/endorsement-chain/index.ts
  • src/core/endorsement-chain/obligation.ts
  • src/obligation-registry-functions/deploy.ts
  • src/obligation-registry-functions/index.ts
  • src/obligation-registry-functions/lifecycle.ts
  • src/obligation-registry-functions/mint.ts
  • src/obligation-registry-functions/ownerOf.ts
  • src/obligation-registry-functions/rejectTransfers.ts
  • src/obligation-registry-functions/returnToken.ts
  • src/obligation-registry-functions/status.ts
  • src/obligation-registry-functions/transfer.ts
  • src/obligation-registry-functions/types.ts
  • src/obligation-registry-functions/utils.ts
  • src/token-registry-v5/contracts.ts
  • src/utils/documents/index.ts
  • src/utils/documents/obligation.ts
  • src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.ts
  • src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.types.ts
  • src/verify/fragments/document-status/obligationRecords/utils.ts
  • src/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.ts
  • src/verify/fragments/index.ts
  • src/verify/verify.ts

Comment thread README.md Outdated
Comment thread src/obligation-registry-functions/mint.ts Outdated
Comment thread src/obligation-registry-functions/ownerOf.ts Outdated
Comment thread src/obligation-registry-functions/status.ts Outdated
Comment thread src/obligation-registry-functions/utils.ts
Comment thread src/obligation-registry-functions/utils.ts
Comment thread src/verify/fragments/document-status/obligationRecords/utils.ts Outdated
manishdex25 and others added 11 commits July 30, 2026 15:47
…est.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@manishdex25
manishdex25 changed the base branch from main to beta-boe July 30, 2026 11:00
@manishdex25
manishdex25 changed the base branch from beta-boe to main July 30, 2026 11:07

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

Caution

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

⚠️ Outside diff range comments (2)
src/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.ts (1)

112-117: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve tokenRegistry validation for transferable records.

The new predicate excludes obligation records but no longer requires a non-empty tokenRegistry. A malformed TransferableRecords status with neither registry address is therefore selected by this verifier and can reach the token-registry RPC path with an undefined address.

Retain the existing tokenRegistry presence check alongside the obligation-record exclusion.

Proposed fix
 credentialStatuses.every(
   (cs: w3cVC.CredentialStatus) =>
-    cs?.type === TRANSFERABLE_RECORDS_TYPE && !isObligationRecordCredentialStatus(cs),
+    cs?.type === TRANSFERABLE_RECORDS_TYPE &&
+    typeof cs?.tokenRegistry === 'string' &&
+    cs.tokenRegistry.length > 0 &&
+    !isObligationRecordCredentialStatus(cs),
 )
🤖 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/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.ts`
around lines 112 - 117, Update the credential-status predicate in the
transferable-record verifier to require a non-empty tokenRegistry while
continuing to exclude obligation-record statuses. Preserve the existing
TRANSFERABLE_RECORDS_TYPE check and ensure malformed statuses without a registry
are not selected for token-registry RPC processing.
src/core/documentBuilder.ts (1)

58-71: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Populate tokenId before signing obligation-record credentials.

W3CObligationRecordsConfig and obligationCredentialStatus() omit tokenId, but sign() overwrites the document status with this incomplete statusConfig. The downstream verifier constructs the lookup token from credentialStatus.tokenId (src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.ts, Lines 42-42), so credentials built through this API reach verification with 0xundefined.

Add tokenId to the configuration and copy it into statusConfig, or preserve and require an existing token ID before signing.

Proposed fix
 export interface W3CObligationRecordsConfig {
+  tokenId: string;
   chain: string;
   chainId: number;
   obligationRegistry: string;
   rpcProviderUrl: string;
 }

 this.statusConfig = {
   type: 'TransferableRecords',
+  tokenId: config.tokenId,
   tokenNetwork: { chain: config.chain, chainId: config.chainId },
   obligationRegistry: config.obligationRegistry,
 };

Also applies to: 174-188

🤖 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/core/documentBuilder.ts` around lines 58 - 71, Update
W3CObligationRecordsConfig and obligationCredentialStatus() to accept a required
tokenId, then ensure sign() copies that value into the statusConfig it writes to
the credential. Preserve the existing chain, chainId, obligationRegistry, and
rpcProviderUrl fields while preventing credentials from being signed with an
undefined tokenId.
🧹 Nitpick comments (1)
src/obligation-registry-functions/status.ts (1)

32-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

isObligationRegistryRegistered silently loses its boolean return typing.

Unlike its sibling readers (getObligationRegistryStatus, getObligationEscrowTerminationReason), which explicitly cast their contract-call results, isObligationRegistryRegistered doesn't cast/annotate its result. Ethers' dynamic Contract index signature types undeclared methods as ContractFunction<any> (returns Promise<any>), so T here is inferred as any — the exported function's return type silently widens from boolean to any for consumers.

🧹 Proposed fix
-const isObligationRegistryRegistered = createEscrowViewReader((contract, options) =>
-  contract.isRegistered({ blockTag: options.blockTag }),
-);
+const isObligationRegistryRegistered = createEscrowViewReader<boolean>(async (contract, options) =>
+  Boolean(await contract.isRegistered({ blockTag: options.blockTag })),
+);
🤖 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/obligation-registry-functions/status.ts` around lines 32 - 46, Update
isObligationRegistryRegistered to explicitly preserve a boolean return type,
either by annotating the callback/result or casting the contract.isRegistered
call to boolean. Keep the existing blockTag option forwarding and reader
structure 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 `@README.md`:
- Line 921: Update the README Obligation/BoE example so
obligationCredentialStatus documents credentialStatus.type as ObligationRecords
rather than TransferableRecords, ensuring the example matches the
ObligationRecords verification flow used by verifyDocument.

In `@src/verify/fragments/document-status/obligationRecords/utils.ts`:
- Around line 32-35: Update the chain ID conversion in the expectedChainId
validation flow to reject malformed strings with trailing characters; use strict
numeric conversion such as Number(chainId) while preserving numeric inputs and
the existing finite-value and network.chainId comparison checks.

---

Outside diff comments:
In `@src/core/documentBuilder.ts`:
- Around line 58-71: Update W3CObligationRecordsConfig and
obligationCredentialStatus() to accept a required tokenId, then ensure sign()
copies that value into the statusConfig it writes to the credential. Preserve
the existing chain, chainId, obligationRegistry, and rpcProviderUrl fields while
preventing credentials from being signed with an undefined tokenId.

In
`@src/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.ts`:
- Around line 112-117: Update the credential-status predicate in the
transferable-record verifier to require a non-empty tokenRegistry while
continuing to exclude obligation-record statuses. Preserve the existing
TRANSFERABLE_RECORDS_TYPE check and ensure malformed statuses without a registry
are not selected for token-registry RPC processing.

---

Nitpick comments:
In `@src/obligation-registry-functions/status.ts`:
- Around line 32-46: Update isObligationRegistryRegistered to explicitly
preserve a boolean return type, either by annotating the callback/result or
casting the contract.isRegistered call to boolean. Keep the existing blockTag
option forwarding and reader structure 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 Plus

Run ID: 650fc8f6-2350-4308-b261-86a10438ac4d

📥 Commits

Reviewing files that changed from the base of the PR and between b63ca01 and 2f87b30.

📒 Files selected for processing (24)
  • .github/workflows/tests.yml
  • README.md
  • src/__tests__/core/documentBuilder.test.ts
  • src/__tests__/core/verify.amoy.test.ts
  • src/__tests__/core/verify.test.ts
  • src/__tests__/e2e/obligation-registry-functions/transfer.e2e.test.ts
  • src/__tests__/obligation-registry-functions/ownerOf.test.ts
  • src/core/documentBuilder.ts
  • src/index.ts
  • src/obligation-registry-functions/deploy.ts
  • src/obligation-registry-functions/lifecycle.ts
  • src/obligation-registry-functions/mint.ts
  • src/obligation-registry-functions/ownerOf.ts
  • src/obligation-registry-functions/rejectTransfers.ts
  • src/obligation-registry-functions/returnToken.ts
  • src/obligation-registry-functions/status.ts
  • src/obligation-registry-functions/transfer.ts
  • src/obligation-registry-functions/utils.ts
  • src/utils/documents/obligation.ts
  • src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.ts
  • src/verify/fragments/document-status/obligationRecords/utils.ts
  • src/verify/fragments/document-status/obligationRecords/verifierHelpers.ts
  • src/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.ts
  • src/verify/fragments/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/obligation-registry-functions/deploy.ts

Comment thread README.md
Comment thread src/verify/fragments/document-status/obligationRecords/utils.ts Outdated
manishdex25 and others added 3 commits July 30, 2026 17:09
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@manishdex25
manishdex25 changed the base branch from main to beta-boe July 30, 2026 12:07

@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/core/documentBuilder.ts (1)

321-330: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject empty obligation-registry configuration values.

typeof value === 'string' accepts empty chain, obligationRegistry, and rpcProviderUrl values. These invalid configurations pass this guard and fail later as misleading network or address errors.

Proposed fix
   return (
-    typeof config?.obligationRegistry === 'string' &&
-    typeof config?.chain === 'string' &&
+    typeof config?.obligationRegistry === 'string' &&
+    config.obligationRegistry.length > 0 &&
+    typeof config?.chain === 'string' &&
+    config.chain.length > 0 &&
     typeof config?.chainId === 'number' &&
-    typeof config?.rpcProviderUrl === 'string'
+    typeof config?.rpcProviderUrl === 'string' &&
+    config.rpcProviderUrl.length > 0
   );
🤖 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/core/documentBuilder.ts` around lines 321 - 330, Update
isObligationRecordsConfig to require non-empty obligationRegistry, chain, and
rpcProviderUrl strings, while retaining the existing numeric chainId validation.
Reject empty values before the configuration is accepted.
🤖 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__/e2e/obligation-registry-functions/statusLifecycle.e2e.test.ts`:
- Line 5: Update the test setup in statusLifecycle.e2e.test.ts to import Chai
and chai-as-promised, then register the plugin with chai.use(chaiAsPromised)
before any assertions use the .rejected or .rejectedWith matchers.

In `@src/core/documentBuilder.ts`:
- Around line 109-113: Reformat the selectedStatusType union declaration to
match the repository’s Prettier output, preserving all existing string-literal
members and the null initializer while eliminating the ESLint formatting
violation.

In `@src/verify/fragments/document-status/obligationRecords/utils.ts`:
- Around line 101-114: Restrict the catch handling around the obligation status
calls so only the expected ownerOf absence revert is converted through
decodeError into notMintedReason. Do not apply the DOCUMENT_NOT_MINTED fallback
to failures from escrow address, active, or isHoldingToken calls; preserve
CodedError propagation and rethrow unexpected RPC or subsequent-call failures so
verification reports ERROR.

---

Outside diff comments:
In `@src/core/documentBuilder.ts`:
- Around line 321-330: Update isObligationRecordsConfig to require non-empty
obligationRegistry, chain, and rpcProviderUrl strings, while retaining the
existing numeric chainId validation. Reject empty values before the
configuration is accepted.
🪄 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: 744cfbd2-59b6-4c27-891e-773d6802432e

📥 Commits

Reviewing files that changed from the base of the PR and between 2f87b30 and 491e732.

📒 Files selected for processing (19)
  • README.md
  • src/__tests__/e2e/fixtures/sample-boe-credential.ts
  • src/__tests__/e2e/obligation-registry-functions/statusLifecycle.e2e.test.ts
  • src/__tests__/e2e/obligation-registry-functions/transfer.e2e.test.ts
  • src/__tests__/fixtures/endorsement-chain.ts
  • src/__tests__/obligation-registry-functions/lifecycle.test.ts
  • src/__tests__/obligation-registry-functions/mint.test.ts
  • src/__tests__/obligation-registry-functions/rejectTransfers.test.ts
  • src/__tests__/obligation-registry-functions/returnToken.test.ts
  • src/__tests__/obligation-registry-functions/status.test.ts
  • src/__tests__/obligation-registry-functions/transfers.test.ts
  • src/__tests__/verify/obligationRecordVerifier.utils.test.ts
  • src/core/documentBuilder.ts
  • src/core/endorsement-chain/fetchEscrowTransfer.ts
  • src/core/endorsement-chain/helpers.ts
  • src/core/endorsement-chain/types.ts
  • src/core/endorsement-chain/useEndorsementChain.ts
  • src/obligation-registry-functions/transfer.ts
  • src/verify/fragments/document-status/obligationRecords/utils.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/tests/obligation-registry-functions/returnToken.test.ts
  • src/tests/obligation-registry-functions/lifecycle.test.ts
  • README.md

Comment thread src/__tests__/e2e/obligation-registry-functions/statusLifecycle.e2e.test.ts Outdated
Comment thread src/core/documentBuilder.ts
Comment thread src/verify/fragments/document-status/obligationRecords/utils.ts Outdated
@manishdex25
manishdex25 changed the base branch from beta-boe to beta July 31, 2026 04:23

@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

Caution

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

⚠️ Outside diff range comments (1)
README.md (1)

34-34: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the broken Overview table-of-contents link.

Line 34 links to #overview-1, but markdownlint reports no matching heading. Use the anchor generated by the Overview heading.

Suggested fix
-      - [Overview](`#overview-1`)
+      - [Overview](`#overview`)
🤖 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 `@README.md` at line 34, Update the Overview table-of-contents entry to
reference the anchor generated by the Overview heading instead of the
nonexistent `#overview-1` target. Change only the link target in the Overview
entry and preserve its displayed text.

Source: Linters/SAST tools

🤖 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 `@README.md`:
- Line 930: Align the BoE credential-status contract across
obligationCredentialStatus(), the status reader, and the ObligationRecords
verifier by using the documented ObligationRecords type with obligationRegistry,
or consistently update the implementation and README to use TransferableRecords.
Ensure the verifier’s type check matches the builder’s emitted wire value.

---

Outside diff comments:
In `@README.md`:
- Line 34: Update the Overview table-of-contents entry to reference the anchor
generated by the Overview heading instead of the nonexistent `#overview-1` target.
Change only the link target in the Overview entry and preserve its displayed
text.
🪄 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: c8130ba0-a30c-4291-93fb-4da9cf383318

📥 Commits

Reviewing files that changed from the base of the PR and between c613ba7 and cafed21.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • .github/workflows/tests.yml
  • README.md
  • package.json
  • src/index.ts
  • src/verify/fragments/document-status/obligationRecords/utils.ts
  • src/verify/fragments/document-status/transferableRecords/utils.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/tests.yml
  • src/index.ts
  • package.json

Comment thread README.md Outdated
@manishdex25
manishdex25 requested a review from rongquan1 July 31, 2026 06:02
@rongquan1

Copy link
Copy Markdown
Contributor

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 56 minutes.

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

🧹 Nitpick comments (2)
src/__tests__/obligation-registry-functions/mint.test.ts (1)

48-79: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the final mint contract arguments.

The tests only verify the encrypt call. They do not verify that mintObligationRegistry sends the encrypted value to the registry.

Assert the beneficiary, holder, token ID, encrypted remarks, and transaction overrides passed to mockTrustVCTokenContract.mint. Also assert that the no-remarks case sends '0x'.

🤖 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__/obligation-registry-functions/mint.test.ts` around lines 48 -
79, The mintObligationRegistry tests currently verify encryption but not the
contract invocation. Extend both “mints with remarks” and “mints without
remarks” cases to assert mockTrustVCTokenContract.mint receives the beneficiary,
holder, token ID, encrypted remarks, and transaction overrides, using the
encrypted value for the remarks case and '0x' when remarks are omitted.
src/utils/documents/obligation.ts (1)

1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Break the barrel-import cycle.

src/utils/documents/obligation.ts imports TRANSFERABLE_RECORDS_TYPE from src/verify/fragments, and src/verify/fragments/index.ts re-exports it from the verifier module. The verifier module imports isObligationRecordCredentialStatus from src/utils/documents/obligation, creating a circular import path across both ESM and CommonJS package entry points. Move TRANSFERABLE_RECORDS_TYPE to a leaf constants module and import it directly from both modules.

🤖 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/documents/obligation.ts` around lines 1 - 4, Move
TRANSFERABLE_RECORDS_TYPE from the verifier/barrel export path into a leaf
constants module, then update obligation.ts and the verifier module to import it
directly from that module. Remove the dependency on src/verify/fragments for
this constant while preserving existing exports and behavior.
🤖 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/core/documentBuilder.ts`:
- Around line 173-194: Update obligationCredentialStatus() to reject calls when
credentialStatus() has already configured the builder, using the same
mutual-exclusivity guard and configuration error behavior as credentialStatus().
Preserve the existing validation and status setup when no conflicting
credential-status configuration exists.
- Around line 401-442: Extract the duplicated chain validation from
verifyObligationRegistry() and verifyTokenRegistry() into a shared private
helper, and reuse it in both methods. Also extract their common try/catch
behavior into a private error-wrapping helper that rethrows the
unsupported-registry error while wrapping other failures as the existing network
error; preserve each method’s current validation and error semantics.

In `@src/obligation-registry-functions/utils.ts`:
- Around line 101-119: Update sendTransaction and the related
executeEscrowMethod, createRemarkEscrowMethod, executeRegistryMethod, and public
mint/transfer/returnToken wrappers to expose the correct ethers v5 or v6
transaction response type based on the contract/signer used. Define and reuse a
shared response type or signer-specific overloads, ensuring ethers v6 calls
return ContractTransactionResponse while preserving ethers v5
ContractTransaction behavior.

In `@src/utils/documents/index.ts`:
- Around line 37-39: Update the transferability classification in
isTransferableRecord to evaluate every credential status using the same
TransferableRecords and non-obligation predicate as verifier test(), ensuring
mixed arrays such as transferable plus obligation are not classified as
transferable.

In `@src/utils/documents/obligation.ts`:
- Around line 33-37: Reject empty credential-status arrays in both predicates:
update the credentialStatuses check in src/utils/documents/obligation.ts lines
33-37 and the corresponding transferable-record verifier check in
src/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.ts
lines 112-117 to require a positive length before calling every, while
preserving validation for non-empty statuses.
- Around line 18-23: Update getObligationRecordsCredentialStatus to return
ObligationRecordsCredentialStatus | undefined, preserving undefined when the
input lacks credentialStatus. Ensure the function’s type and any affected
callers reflect that the returned status may be absent.

In
`@src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.ts`:
- Around line 33-37: Update verify to filter credentialStatuses to supported
obligation-status entries before passing them onward, so unrelated supported
credential-status types do not suppress obligation verification. In test, use
some to return true when any credential status matches an obligation type rather
than requiring every entry to match. Apply the same behavior to the
corresponding logic around the additional referenced section.
- Around line 83-87: Update the invalid-result branch in
obligationRecordVerifier so result.reason is taken from the first entry in
verificationResult that fails ValidTokenRegistryStatus.guard, rather than always
reading index 0. Preserve the existing VALID behavior and assign the selected
invalid status’s reason to the returned result.

In
`@src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.types.ts`:
- Around line 27-29: Apply the repository’s required Prettier formatting to the
ObligationRecordsVerificationFragment type union, using the formatter’s
multiline layout for the union members so ESLint passes.

---

Nitpick comments:
In `@src/__tests__/obligation-registry-functions/mint.test.ts`:
- Around line 48-79: The mintObligationRegistry tests currently verify
encryption but not the contract invocation. Extend both “mints with remarks” and
“mints without remarks” cases to assert mockTrustVCTokenContract.mint receives
the beneficiary, holder, token ID, encrypted remarks, and transaction overrides,
using the encrypted value for the remarks case and '0x' when remarks are
omitted.

In `@src/utils/documents/obligation.ts`:
- Around line 1-4: Move TRANSFERABLE_RECORDS_TYPE from the verifier/barrel
export path into a leaf constants module, then update obligation.ts and the
verifier module to import it directly from that module. Remove the dependency on
src/verify/fragments for this constant while preserving existing exports and
behavior.
🪄 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: 9dd12c65-7e9b-4dea-a157-bb84de6b90e3

📥 Commits

Reviewing files that changed from the base of the PR and between bc3eba0 and c8ea6b3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (52)
  • .github/workflows/tests.yml
  • README.md
  • package.json
  • src/__tests__/core/documentBuilder.test.ts
  • src/__tests__/core/verify.amoy.test.ts
  • src/__tests__/core/verify.test.ts
  • src/__tests__/e2e/fixtures/sample-boe-credential.ts
  • src/__tests__/e2e/obligation-registry-functions/fixtures.ts
  • src/__tests__/e2e/obligation-registry-functions/statusLifecycle.e2e.test.ts
  • src/__tests__/e2e/obligation-registry-functions/transfer.e2e.test.ts
  • src/__tests__/e2e/utils.ts
  • src/__tests__/fixtures/endorsement-chain.ts
  • src/__tests__/obligation-registry-functions/deploy.test.ts
  • src/__tests__/obligation-registry-functions/fixtures.ts
  • src/__tests__/obligation-registry-functions/lifecycle.test.ts
  • src/__tests__/obligation-registry-functions/mint.test.ts
  • src/__tests__/obligation-registry-functions/ownerOf.test.ts
  • src/__tests__/obligation-registry-functions/rejectTransfers.test.ts
  • src/__tests__/obligation-registry-functions/returnToken.test.ts
  • src/__tests__/obligation-registry-functions/status.test.ts
  • src/__tests__/obligation-registry-functions/transfers.test.ts
  • src/__tests__/verify/obligationRecordVerifier.utils.test.ts
  • src/core/documentBuilder.ts
  • src/core/endorsement-chain/fetchEscrowTransfer.ts
  • src/core/endorsement-chain/helpers.ts
  • src/core/endorsement-chain/index.ts
  • src/core/endorsement-chain/obligation.ts
  • src/core/endorsement-chain/types.ts
  • src/core/endorsement-chain/useEndorsementChain.ts
  • src/index.ts
  • src/obligation-registry-functions/deploy.ts
  • src/obligation-registry-functions/index.ts
  • src/obligation-registry-functions/lifecycle.ts
  • src/obligation-registry-functions/mint.ts
  • src/obligation-registry-functions/ownerOf.ts
  • src/obligation-registry-functions/rejectTransfers.ts
  • src/obligation-registry-functions/returnToken.ts
  • src/obligation-registry-functions/status.ts
  • src/obligation-registry-functions/transfer.ts
  • src/obligation-registry-functions/types.ts
  • src/obligation-registry-functions/utils.ts
  • src/token-registry-v5/contracts.ts
  • src/utils/documents/index.ts
  • src/utils/documents/obligation.ts
  • src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.ts
  • src/verify/fragments/document-status/obligationRecords/obligationRecordVerifier.types.ts
  • src/verify/fragments/document-status/obligationRecords/utils.ts
  • src/verify/fragments/document-status/obligationRecords/verifierHelpers.ts
  • src/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.ts
  • src/verify/fragments/document-status/transferableRecords/utils.ts
  • src/verify/fragments/index.ts
  • src/verify/verify.ts

Comment thread src/core/documentBuilder.ts Outdated
Comment thread src/core/documentBuilder.ts Outdated
Comment thread src/obligation-registry-functions/utils.ts
Comment thread src/utils/documents/index.ts Outdated
Comment thread src/utils/documents/obligation.ts Outdated
Comment thread src/utils/documents/obligation.ts Outdated
manishdex25 and others added 4 commits July 31, 2026 12:25
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…ionRecordVerifier.types.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@rongquan1
rongquan1 merged commit 2a3cf11 into beta Jul 31, 2026
10 checks passed
@rongquan1
rongquan1 deleted the feature/boe-v2 branch July 31, 2026 08:44
nghaninn pushed a commit that referenced this pull request Jul 31, 2026
## [2.15.0-beta.3](v2.15.0-beta.2...v2.15.0-beta.3) (2026-07-31)

### Features

* implement obligation registry functions and enhance document bu… ([#155](#155)) ([2a3cf11](2a3cf11))

### Bug Fixes

* boe heap issue ([#156](#156)) ([b997db7](b997db7))
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.15.0-beta.3 🎉

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants