fix(sdk): honor nullable return type in getSpotMarketAccount#2188
fix(sdk): honor nullable return type in getSpotMarketAccount#2188shubhamessier wants to merge 1 commit into
getSpotMarketAccount#2188Conversation
`driftClient.getSpotMarketAccount()` and `forceGetSpotMarketAccount()` are declared to return `SpotMarketAccount | undefined`, but currently dereference `.data` on the underlying `DataAndSlot<...> | undefined` returned by `accountSubscriber`. This causes a `TypeError` when the requested `marketIndex` is not present in the subscriber cache. Use optional chaining when accessing `.data` so the implementation matches the declared return type and correctly returns `undefined` when the account is unavailable. This ensures external consumers can safely handle the nullable return path without encountering runtime exceptions. Closes velocity-exchange#2137.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesSpot market account lookup safety
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @lowkeynicc can you kindly review the changes once, thanks! cc: @LukasDeco |
driftClient.getSpotMarketAccount()andforceGetSpotMarketAccount()are declared to returnSpotMarketAccount | undefined, but currently dereference.dataon the underlyingDataAndSlot<...> | undefinedreturned byaccountSubscriber.This causes a
TypeErrorwhen the requestedmarketIndexis not present in the subscriber cache.Use optional chaining when accessing
.dataso the implementation matches the declared return type and correctly returnsundefinedwhen the account is unavailable.This ensures external consumers can safely handle the nullable return path without encountering runtime exceptions.
Closes #2137.
Summary by CodeRabbit
Bug Fixes