Skip to content

Commit 02a4e77

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, consistent with how the wallet already owns its own data. 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 6a45ec4 commit 02a4e77

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ export class ActiveOperationExistsError extends Error {
4949
export class DefiVault implements IDefiVault {
5050
private readonly wallet: IWallet;
5151
private readonly bitgo: BitGoBase;
52-
private readonly _enterpriseId: string;
5352

54-
constructor(wallet: IWallet, enterpriseId: string) {
53+
constructor(wallet: IWallet) {
5554
this.wallet = wallet;
5655
this.bitgo = wallet.bitgo;
57-
this._enterpriseId = enterpriseId;
5856
}
5957

6058
/**
@@ -67,7 +65,7 @@ export class DefiVault implements IDefiVault {
6765
}
6866
const raw = await this.bitgo
6967
.get(this.bitgo.microservicesUrl(`/api/defi-service/v1/vaults/${params.vaultId}`))
70-
.set('enterprise-id', this._enterpriseId)
68+
.set('enterprise-id', this.wallet.toJSON().enterprise)
7169
.result();
7270
return decodeWithCodec(GetVaultResponse, raw, 'getVaultConfig');
7371
}

modules/sdk-core/src/bitgo/wallet/wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3301,7 +3301,7 @@ export class Wallet implements IWallet {
33013301
*/
33023302
get defi(): DefiVault {
33033303
if (!this._defi) {
3304-
this._defi = new DefiVault(this, this._wallet.enterprise);
3304+
this._defi = new DefiVault(this);
33053305
}
33063306
return this._defi;
33073307
}

0 commit comments

Comments
 (0)