Skip to content

fix(sdk-core): read defi vault operationId from coinSpecific#9067

Merged
kamleshmugdiya merged 1 commit into
masterfrom
kamleshmugdiya/cgd-1829-defi-operationid-coinspecific
Jun 19, 2026
Merged

fix(sdk-core): read defi vault operationId from coinSpecific#9067
kamleshmugdiya merged 1 commit into
masterfrom
kamleshmugdiya/cgd-1829-defi-operationid-coinspecific

Conversation

@kamleshmugdiya

@kamleshmugdiya kamleshmugdiya commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

DefiVault.depositToVault() threw Error: operationId not found in approve txRequest response on every deposit. The approve sendMany succeeded and the WP minted an operationId, but the SDK couldn't locate it and aborted before issuing the deposit sendMany.

Root cause: a contract mismatch on where operationId lives in the approve txRequest response.

  • SDKextractOperationId() read txRequest.intent.operationId.
  • WP — writes the defi-service-minted operationId into the built transaction's coinSpecific (next to assignedNonce), which for a full txRequest surfaces at txRequest.transactions[0].unsignedTx.coinSpecific.operationId. The intent block never carries it.

Both the SDK comment and the WP docstring claimed "operationId on the intent," and the SDK unit test mocked the response that way — so the bug shipped with green tests on both sides.

Changes

  • extractOperationId() now reads transactions[0].unsignedTx.coinSpecific.operationId (full apiVersion), falling back to unsignedTxs[0].coinSpecific.operationId (lite) and finally intent.operationId (forward-compat, in case WP later also populates the intent).
  • Updated the misleading docstring in defiVault.ts.
  • Fixed the stale unit-test mocks that put operationId on the intent and masked the regression — the approve mocks now use the real coinSpecific shape.
  • Added regression tests covering the lite shape, the intent forward-compat fallback, and the not-found path.

Test plan

  • mocha test/unit/bitgo/defi/defiVault.ts — 17 passing, 1 pending (CGD-1709 placeholder)
  • eslint — 0 errors
  • prettier --check — clean

Ticket: CGD-1829

extractOperationId() read txRequest.intent.operationId, but the WP
writes the minted operationId into the built transaction's coinSpecific.
Read it from transactions[0].unsignedTx.coinSpecific (full apiVersion),
falling back to unsignedTxs[0].coinSpecific (lite) and intent.operationId
(forward-compat).

Fix the stale unit-test mock that put operationId on the intent and
masked the bug, and add regression tests for the lite, intent-fallback,
and not-found paths.

Ticket: CGD-1829

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 19, 2026

Copy link
Copy Markdown

CGD-1829

@kamleshmugdiya kamleshmugdiya self-assigned this Jun 19, 2026
@kamleshmugdiya kamleshmugdiya marked this pull request as ready for review June 19, 2026 08:38
@kamleshmugdiya kamleshmugdiya requested review from a team as code owners June 19, 2026 08:38
Comment thread modules/sdk-core/src/bitgo/defi/defiVault.ts
@kamleshmugdiya kamleshmugdiya merged commit ad469ff into master Jun 19, 2026
24 checks passed
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.

3 participants