Repository navigation
feat(sdk-core): map the D7 deposit stop to a typed resume-recovery error - #10323
Draft
mullapudipruthvik wants to merge 1 commit into
Draft
mullapudipruthvik wants to merge 1 commit into
mullapudipruthvik wants to merge 1 commit into
Conversation
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
Contributor
Contributor
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
DepositStoppedForApproveApprovalErrorsubclass ofActiveOperationExistsError— carriesoperationId,vaultId,assetAmount, andapprovePendingApprovalId(the approve leg's PA). Existing catch blocks keep working via the base class; callers narrow withinstanceofto render the explicit approve-PA screen instead of auto-resuming.DEPOSIT_STOPPED_APPROVE_PA_ERROR_CODE = 'defi_deposit_stopped_approve_pa'(machine-readable, matched againstApiResponseError.result.code— the authoritative detection) andDEPOSIT_STOPPED_FOR_OPEN_APPROVE_PAmessage fragment (secondary fallback for code-less bodies). The code constant is the WP<->SDK contract and should be promoted into@bitgo/public-typeswhen DEF-1511 implements the stop.resumeDeposittreats 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.depositis now optional inErc4626DepositResult) — sign the approve, resume again, the deposit leg materializes.causeon 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 --noEmitclean.Ticket: DEFI-1512