diff --git a/modules/sdk-core/src/bitgo/defi/defiVault.ts b/modules/sdk-core/src/bitgo/defi/defiVault.ts index 150d1d44ad..63071f38f3 100644 --- a/modules/sdk-core/src/bitgo/defi/defiVault.ts +++ b/modules/sdk-core/src/bitgo/defi/defiVault.ts @@ -52,7 +52,8 @@ export class DefiVault implements IDefiVault { * * Internally issues two sendMany calls (approve + deposit) and returns the * operationId that links them. If the deposit sendMany fails after - * the approve succeeds, the approve is auto-cancelled (fail-fast). + * the approve succeeds, the error propagates — the server-side reconciler + * handles orphaned approvals. * * @param params.vaultId - DeFi-service vault identifier * @param params.amount - amount in base units of the underlying asset @@ -67,15 +68,16 @@ export class DefiVault implements IDefiVault { throw new Error('amount is required'); } - // Layer-1 pre-flight: reject if an active deposit already exists for this (wallet, vault) - const activeOps: DefiOperationListResult = await this.bitgo - .get(this.bitgo.microservicesUrl(this.operationsUrl())) - .query({ vaultId: params.vaultId, state: 'active' }) - .result(); - - if (activeOps.items && activeOps.items.length > 0) { - throw new ActiveOperationExistsError(activeOps.items[0].operationId); - } + // TODO(CGD-1709): Re-enable active operation pre-flight check once the + // defi-service operations endpoint is deployed and returning active state. + // const activeOps: DefiOperationListResult = await this.bitgo + // .get(this.bitgo.microservicesUrl(this.operationsUrl())) + // .query({ vaultId: params.vaultId, state: 'active' }) + // .result(); + // + // if (activeOps.items && activeOps.items.length > 0) { + // throw new ActiveOperationExistsError(activeOps.items[0].operationId); + // } // Step 1: Approve txRequest via sendMany const approveResult = await this.wallet.sendMany({ diff --git a/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts b/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts index c4c810d06b..6a4377c920 100644 --- a/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts +++ b/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts @@ -54,10 +54,6 @@ describe('DefiVault', function () { it('should call sendMany for approve and deposit on happy path', async function () { const operationId = 'op-uuid-123'; - // Pre-flight: no active operations - const preflightReq = mockRequest({ items: [] }); - mockBitGo.get.onFirstCall().returns(preflightReq); - // Mock sendMany for approve and deposit const sendManyStub = sinon.stub(wallet, 'sendMany'); sendManyStub.onFirstCall().resolves({ @@ -82,9 +78,6 @@ describe('DefiVault', function () { result.txRequestIds.approve.should.equal('txreq-approve-1'); result.txRequestIds.deposit.should.equal('txreq-deposit-1'); - // Verify pre-flight was called with correct query - preflightReq.query.calledWith({ vaultId: 'vlt-galaxy-usdc', state: 'active' }).should.be.true(); - // Verify sendMany was called with correct params for approve sendManyStub.calledTwice.should.be.true(); const approveArgs: any = sendManyStub.firstCall.args[0]; @@ -98,7 +91,8 @@ describe('DefiVault', function () { depositArgs.defiParams.operationId.should.equal(operationId); }); - it('should reject when an active operation already exists', async function () { + // TODO(CGD-1709): Re-enable when active operation pre-flight check is restored + xit('should reject when an active operation already exists', async function () { const preflightReq = mockRequest({ items: [{ operationId: 'existing-op-id', state: 'APPROVE_TX_REQUESTED' }], }); @@ -117,10 +111,6 @@ describe('DefiVault', function () { it('should propagate deposit sendMany failure without cleanup', async function () { const operationId = 'op-uuid-456'; - // Pre-flight: no active operations - const preflightReq = mockRequest({ items: [] }); - mockBitGo.get.returns(preflightReq); - // Mock sendMany: approve succeeds, deposit fails const sendManyStub = sinon.stub(wallet, 'sendMany'); sendManyStub.onFirstCall().resolves({ @@ -154,9 +144,6 @@ describe('DefiVault', function () { it('should pass clientIdempotencyKey and walletPassphrase when provided', async function () { const operationId = 'op-uuid-789'; - const preflightReq = mockRequest({ items: [] }); - mockBitGo.get.returns(preflightReq); - const sendManyStub = sinon.stub(wallet, 'sendMany'); sendManyStub.onFirstCall().resolves({ txRequest: {