Skip to content

feat(sdk): [BBND-1775] resolveLatestConfigVersion + reject configVersion < 1#1191

Merged
MiguelLZPF merged 3 commits into
developmentfrom
feat/BBND-1775-sdk-explicit-version
May 25, 2026
Merged

feat(sdk): [BBND-1775] resolveLatestConfigVersion + reject configVersion < 1#1191
MiguelLZPF merged 3 commits into
developmentfrom
feat/BBND-1775-sdk-explicit-version

Conversation

@MiguelLZPF

Copy link
Copy Markdown
Contributor

Description

PR 2 of the BBND-1775 series (contracts → SDK → web). Aligns the SDK with the
contract-side VersionZero(configurationId) revert introduced in PR 1
(#1188).

  • New Management.resolveLatestConfigVersion({ resolverAddress, configurationId })
    port-in method, backed by ResolveLatestConfigVersionQuery + handler and a
    new RPCQueryAdapter.getLatestVersionByConfiguration call that talks to
    DiamondCutManager directly. Callers that previously relied on
    configVersion: 0 to track "latest" now resolve the explicit number with
    this query and pin it.
  • Tightens validation on every request that carries a configVersion
    (CreateEquityRequest, CreateBondRequest, CreateBondFixedRateRequest,
    UpdateConfigVersionRequest, UpdateConfigRequest, UpdateResolverRequest)
    via a shared MIN_CONFIG_VERSION = 1 constant in @core/Constants.
  • Updates the CreateEquity / CreateBond / CreateBondFixedRate /
    CreateBondKpiLinkedRate command handlers to extend the existing
    undefined guard to also reject sub-1 values, with a message pointing
    callers at the new query.

This PR is stacked on #1188; merge order is contracts first, then SDK.

Refs: BBND-1775

Type of change

  • Bug fix 🐞
  • New feature ✨
  • Breaking change 💥
  • Documentation update 📖
  • Refactor 🔧

Testing

  • `npm run --workspace=packages/ats/sdk format` → clean.
  • `npm run --workspace=packages/ats/sdk lint` → 0 errors (2 baseline warnings unchanged).
  • `npm run ats:sdk:build` → passes (ESM + CJS).
  • `npm run ats:sdk:test` → 1902 passing, 26 failing, 1928 total.
    The 26 failures live in 5 custodial-adapter suites
    (`Kyc.test.ts`, `Security.test.ts`, `AWSKMSTransactionAdapter.test.ts`,
    `DFNSTransactionAdapter.test.ts`, `FireblocksTransactionAdapter.test.ts`)
    and match the documented `.env`-dependent baseline. All
    Management / Equity / Bond / Coupon suites pass; the
    `Management.resolveLatestConfigVersion` describe block and the new
    configVersion = 0 cases on the create-flow handlers all pass.

New tests added:

  • `Management.unit.test.ts` → `resolveLatestConfigVersion` happy path,
    query-bus failure, invalid resolverAddress, non-bytes32 configurationId,
    and explicit "configVersion is zero" cases for the
    updateConfigVersion / updateConfig / updateResolver blocks.
  • `ResolveLatestConfigVersionQueryHandler.unit.test.ts` → happy path
    and error wrapping into `ResolveLatestConfigVersionQueryError`.
  • `CreateEquity` / `CreateBond` / `CreateBondFixedRate` /
    `CreateBondKpiLinkedRate` command-handler unit tests → message
    alignment + `configVersion: 0` rejection.

Test Results (if any)

`npm run ats:sdk:test` → 1902 passing / 1928 total / 26 baseline
custodial-adapter failures (no .env locally).

Node version:

  • 20
  • 22
  • 24

Checklist

  • Style Guidelines followed ✅
  • Documentation Updated 📚
  • Linters - No New Warnings ⚠️
  • Local Tests Pass ✅
  • Effective Tests Added ✔️
  • No reduction of Coverage

@MiguelLZPF MiguelLZPF self-assigned this May 22, 2026
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-contracts-explicit-version branch from bbafa19 to f25fdd4 Compare May 25, 2026 06:40
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-sdk-explicit-version branch from 50e0756 to 177d376 Compare May 25, 2026 06:50
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-contracts-explicit-version branch from f25fdd4 to da9de75 Compare May 25, 2026 07:54
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-sdk-explicit-version branch from 177d376 to 6587f6c Compare May 25, 2026 07:55
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-contracts-explicit-version branch from da9de75 to c09d0e5 Compare May 25, 2026 08:35
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-sdk-explicit-version branch 2 times, most recently from 9e5425d to 247ad15 Compare May 25, 2026 08:55
@MiguelLZPF MiguelLZPF marked this pull request as ready for review May 25, 2026 09:32
@MiguelLZPF MiguelLZPF requested review from a team as code owners May 25, 2026 09:32
@MiguelLZPF MiguelLZPF requested a review from RaphaelMessian May 25, 2026 09:32
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-sdk-explicit-version branch from 247ad15 to 6def63b Compare May 25, 2026 12:42
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-contracts-explicit-version branch from c09d0e5 to cf4d8bf Compare May 25, 2026 12:53
Base automatically changed from feat/BBND-1775-contracts-explicit-version to development May 25, 2026 12:54
Introduces `Management.resolveLatestConfigVersion({ resolverAddress,
configurationId })` so SDK consumers can resolve the latest
registered configuration version explicitly before pinning it on a
write call.

The query reads `DiamondCutManager.getLatestVersionByConfiguration`
on the supplied resolver via a new
`RPCQueryAdapter.getLatestVersionByConfiguration(resolverAddress,
configurationId)`. Wiring follows the existing CQRS plumbing:
`ResolveLatestConfigVersionRequest` (port-in) →
`ResolveLatestConfigVersionQuery` → handler decorated with
`@QueryHandler`. The handler is registered alongside the existing
ones in `QUERY_HANDLERS_RESOLVER`.

This pairs with the contract-side `VersionZero` revert from PR 1:
callers can no longer rely on `version == 0` to mean "latest"; they
must resolve the explicit number first.

Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
Tightens validation on every request that carries a `configVersion`
and on every create-flow command handler so 0 (and any other
sub-1 value) is rejected at the SDK boundary instead of leaking
through to the chain.

Introduces a shared `MIN_CONFIG_VERSION = 1` constant in
`@core/Constants`, paired with the on-chain `VersionZero` revert.
`CreateEquityRequest`, `CreateBondRequest`,
`CreateBondFixedRateRequest`, `UpdateConfigVersionRequest`,
`UpdateConfigRequest`, and `UpdateResolverRequest` all use
`FormatValidation.checkNumber({ min: MIN_CONFIG_VERSION })`.

`CreateEquity` / `CreateBond` / `CreateBondFixedRate` /
`CreateBondKpiLinkedRate` command handlers extend the existing
`undefined` guard to also reject sub-1 values, with the new error
message pointing callers at `Management.resolveLatestConfigVersion`
when they need the latest version.

Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
Brings the SDK test suite in line with the rejection rules:

- `Management.unit.test.ts`: new `resolveLatestConfigVersion`
  describe block (happy path, query-bus failure, invalid
  resolverAddress, non-bytes32 configurationId). Adds explicit
  "configVersion is zero" cases to the existing
  updateConfigVersion / updateConfig / updateResolver blocks.
- `Create{Equity,Bond,BondFixedRate,BondKpiLinkedRate}CommandHandler.unit.test.ts`:
  update the legacy "Config Version not found" assertions to
  match the new "Config Version must be >= 1" message and add a
  parallel `configVersion: 0` case.
- `ResolveLatestConfigVersionQueryHandler.unit.test.ts`: new file
  covering the happy path and error wrapping into
  `ResolveLatestConfigVersionQueryError`.
- `__tests__/port/in/{Bond,Coupon}.test.ts` and
  `__tests__/port/out/{AWSKMS,DFNS,Fireblocks}TransactionAdapter.test.ts`:
  promote the shared `const configVersion = 0` fixture to `1`
  so the deeper flows exercising request validation no longer
  trip the new guard.

Adds a changeset capturing the new query, the
`MIN_CONFIG_VERSION` constant, and the tightened request /
handler validation.

Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
@MiguelLZPF MiguelLZPF force-pushed the feat/BBND-1775-sdk-explicit-version branch from 6def63b to 24ee150 Compare May 25, 2026 13:31
@MiguelLZPF MiguelLZPF merged commit 24ee150 into development May 25, 2026
14 checks passed
@MiguelLZPF MiguelLZPF deleted the feat/BBND-1775-sdk-explicit-version branch May 25, 2026 13:48
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.

2 participants