Skip to content

Commit 17fd5cb

Browse files
venkateshv1266bitgobot
authored andcommitted
fix(sdk-core): stamp enterprise-id header on getVaultConfig call
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
1 parent 90d0c0f commit 17fd5cb

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

modules/sdk-core/src/bitgo/defi/defiVault.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class DefiVault implements IDefiVault {
6565
}
6666
const raw = await this.bitgo
6767
.get(this.bitgo.microservicesUrl(`/api/defi-service/v1/vaults/${params.vaultId}`))
68+
.set('enterprise-id', this.wallet.toJSON().enterprise)
6869
.result();
6970
return decodeWithCodec(GetVaultResponse, raw, 'getVaultConfig');
7071
}

modules/sdk-core/test/unit/bitgo/defi/defiVault.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('DefiVault', function () {
1414
function mockRequest(result: any) {
1515
return {
1616
send: sinon.stub().returnsThis(),
17+
set: sinon.stub().returnsThis(),
1718
query: sinon.stub().returnsThis(),
1819
result: sinon.stub().resolves(result),
1920
};
@@ -71,6 +72,7 @@ describe('DefiVault', function () {
7172
id: 'test-wallet-id',
7273
coin: 'eth',
7374
keys: ['user-key', 'backup-key', 'bitgo-key'],
75+
enterprise: 'test-enterprise-id',
7476
};
7577

7678
wallet = new Wallet(mockBitGo, mockBaseCoin, mockWalletData);
@@ -110,6 +112,7 @@ describe('DefiVault', function () {
110112

111113
result.should.deepEqual(vaultConfig);
112114
mockBitGo.get.calledWith('https://bitgo.com/api/defi-service/v1/vaults/vlt-concrete-1').should.be.true();
115+
req.set.calledWith('enterprise-id', 'test-enterprise-id').should.be.true();
113116
});
114117

115118
it('should throw if vaultId is missing', async function () {

0 commit comments

Comments
 (0)