From 20135a7838570d55ff491c9e9c7298e0ddf0fced Mon Sep 17 00:00:00 2001 From: MrBlackGhostt Date: Mon, 15 Jun 2026 23:53:13 +0530 Subject: [PATCH] fix: add optional chaining to spot market account retrievals --- sdk/src/driftClient.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/src/driftClient.ts b/sdk/src/driftClient.ts index 54a6c636b7..2ecbf79bf2 100644 --- a/sdk/src/driftClient.ts +++ b/sdk/src/driftClient.ts @@ -696,7 +696,8 @@ export class DriftClient { public getSpotMarketAccount( marketIndex: number ): SpotMarketAccount | undefined { - return this.accountSubscriber.getSpotMarketAccountAndSlot(marketIndex).data; + return this.accountSubscriber.getSpotMarketAccountAndSlot(marketIndex) + ?.data; } /** @@ -707,7 +708,8 @@ export class DriftClient { marketIndex: number ): Promise { await this.accountSubscriber.fetch(); - return this.accountSubscriber.getSpotMarketAccountAndSlot(marketIndex).data; + return this.accountSubscriber.getSpotMarketAccountAndSlot(marketIndex) + ?.data; } public getSpotMarketAccounts(): SpotMarketAccount[] {