Skip to content

feat(sdk-core): map the D7 deposit stop to a typed resume-recovery error - #10323

Draft
mullapudipruthvik wants to merge 1 commit into
masterfrom
pruthvikpruthvik/defi-1512-sdk-handle-d7-stop
Draft

mullapudipruthvik wants to merge 1 commit into
masterfrom
pruthvikpruthvik/defi-1512-sdk-handle-d7-stop

Conversation

@mullapudipruthvik

Copy link
Copy Markdown
Contributor

Summary

Wallet Platform will soon refuse hot-wallet defi deposit-leg creates with a 409 while the operation's approve leg has an unresolved pending approval (the D7 decision in the self-custody TDD; WP-side enforcement is DEFI-1511, not yet implemented). This makes that stop recoverable in the SDK:

  • New DepositStoppedForApproveApprovalError subclass of ActiveOperationExistsError — carries operationId, vaultId, assetAmount, and approvePendingApprovalId (the approve leg's PA). Existing catch blocks keep working via the base class; callers narrow with instanceof to render the explicit approve-PA screen instead of auto-resuming.
  • New exported constants: DEPOSIT_STOPPED_APPROVE_PA_ERROR_CODE = 'defi_deposit_stopped_approve_pa' (machine-readable, matched against ApiResponseError.result.code — the authoritative detection) and DEPOSIT_STOPPED_FOR_OPEN_APPROVE_PA message fragment (secondary fallback for code-less bodies). The code constant is the WP<->SDK contract and should be promoted into @bitgo/public-types when DEF-1511 implements the stop.
  • resumeDeposit treats the same stop as a state, not an error: while the approve leg is not signed-or-later, resume returns the approve-only state (txRequestIds.deposit is now optional in Erc4626DepositResult) — sign the approve, resume again, the deposit leg materializes.
  • The original 409 is preserved as cause on the mapped error (requestId correlation with WP logs).

Test plan

modules/sdk-core/test/unit/bitgo/defi/defiVault.ts — 10 new/extended tests: mapping (code+fragment, code-only, fragment-only fallback, non-409 passthrough), message + cause assertions, unrelated-409 passthrough (strictEqual same object), resume approve-only state, resume unrelated-error propagation, resume passphrase forwarding, and the pre-flight back-compat guard (must not be the subclass). Suite 119 passing, tsc --noEmit clean.

Ticket: DEFI-1512

Wallet Platform (DEFI-1511) refuses the deposit-leg create with a 409
Conflict while the operation's approve leg has an unresolved pending
approval (hot wallets). Map that one error to the new
DepositStoppedForApproveApprovalError subclass — which extends
ActiveOperationExistsError, so existing catch blocks keep working —
carrying the operationId, vaultId, amount, and the approve leg's
pending-approval id, so callers render the explicit approve-PA
screen instead of auto-resuming (resume at that moment is known to
return "not yet"). Unrelated 409s propagate unchanged.

Detection is the machine-readable error code first (result.code,
DEPOSIT_STOPPED_APPROVE_PA_ERROR_CODE = defi_deposit_stopped_approve_pa
— to be promoted into @bitgo/public-types so WP and the SDK are
compile-time checked against the same constant) with the stable
message fragment as a secondary fallback for code-less bodies.

resumeDeposit treats the same stop as a state, not an error: while the
approve leg is not signed-or-later (open PA or approved-but-unsigned),
resume returns the approve-only state — txRequestIds.deposit is now
optional — and the caller signs the approve and resumes again; the
deposit leg materializes once the approve is signed-or-later.

Ticket: DEFI-1512
@linear-code

linear-code Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

DEFI-1512

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

⚠️ Compatibility checks are failing on Node.js 27-nightly (experimental, non-blocking). This does not block merge, but it signals an incompatibility to fix before this release becomes supported.

View run

This branch has not been deployed

No deployments
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