From 55a01501db2f393430fd702bd6a8fc2ddf7e96db Mon Sep 17 00:00:00 2001 From: Venkatesh V Date: Mon, 27 Jul 2026 15:41:48 +0000 Subject: [PATCH] fix(sdk-core): stamp enterprise-id header on getVaultConfig call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DefiVault.getVaultConfig() was calling the defi-service vault config endpoint without the `enterprise-id` header that defi-service requires. This caused the entire deposit flow to fail for UI clients whose access tokens don't have `accessToken.enterprise` populated as a fallback in WP's auth resolution. Fix: call `.set('enterprise-id', this.wallet.toJSON().enterprise)` on the GET request. The enterprise id is sourced directly from the wallet context via the IWallet.toJSON() accessor — no constructor change needed. Tests: add `enterprise: 'test-enterprise-id'` to mock wallet data, add `set: sinon.stub().returnsThis()` to mockRequest helper, and assert `.set('enterprise-id', 'test-enterprise-id')` is called on the GET. Ticket: DEFI-496 Session-Id: 1434552b-96ce-4eac-9922-cc2288aa5054 Task-Id: ba541f90-9eb1-45ed-a30f-a0605abde178 --- modules/sdk-core/src/bitgo/defi/defiVault.ts | 1 + modules/sdk-core/test/unit/bitgo/defi/defiVault.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/modules/sdk-core/src/bitgo/defi/defiVault.ts b/modules/sdk-core/src/bitgo/defi/defiVault.ts index ec9641ec75..59a4f8e281 100644 --- a/modules/sdk-core/src/bitgo/defi/defiVault.ts +++ b/modules/sdk-core/src/bitgo/defi/defiVault.ts @@ -65,6 +65,7 @@ export class DefiVault implements IDefiVault { } const raw = await this.bitgo .get(this.bitgo.microservicesUrl(`/api/defi-service/v1/vaults/${params.vaultId}`)) + .set('enterprise-id', this.wallet.toJSON().enterprise) .result(); return decodeWithCodec(GetVaultResponse, raw, 'getVaultConfig'); } diff --git a/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts b/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts index 4e91d40699..900e895884 100644 --- a/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts +++ b/modules/sdk-core/test/unit/bitgo/defi/defiVault.ts @@ -14,6 +14,7 @@ describe('DefiVault', function () { function mockRequest(result: any) { return { send: sinon.stub().returnsThis(), + set: sinon.stub().returnsThis(), query: sinon.stub().returnsThis(), result: sinon.stub().resolves(result), }; @@ -71,6 +72,7 @@ describe('DefiVault', function () { id: 'test-wallet-id', coin: 'eth', keys: ['user-key', 'backup-key', 'bitgo-key'], + enterprise: 'test-enterprise-id', }; wallet = new Wallet(mockBitGo, mockBaseCoin, mockWalletData); @@ -110,6 +112,7 @@ describe('DefiVault', function () { result.should.deepEqual(vaultConfig); mockBitGo.get.calledWith('https://bitgo.com/api/defi-service/v1/vaults/vlt-concrete-1').should.be.true(); + req.set.calledWith('enterprise-id', 'test-enterprise-id').should.be.true(); }); it('should throw if vaultId is missing', async function () {