@@ -24,7 +24,6 @@ import {
2424 buildHttpClientOverrideFromMetadata ,
2525} from "./helpers" ;
2626
27-
2827const packageDef = protoLoader . fromJSON (
2928 descriptor as unknown as Record < string , unknown > ,
3029) ;
@@ -215,14 +214,17 @@ export function getServer(
215214 }
216215 case Action . FetchAccountId : {
217216 try {
218- let accountId : string ;
219- let uid : string ;
217+ let accountId : string | undefined ;
218+ let uid : string | undefined ;
220219
221- const temp_broker = ( broker as any )
220+ const temp_broker = broker as any ;
222221
223222 // 1. Bybit-style method?
224223 if ( typeof temp_broker . privateGetV5UserQueryApi === "function" ) {
225224 const query = await temp_broker . privateGetV5UserQueryApi ( ) ;
225+ if ( ! query ?. id || ! query ?. userID ) {
226+ throw new Error ( "Invalid response structure from privateGetV5UserQueryApi" ) ;
227+ }
226228 accountId = query . id ;
227229 uid = query . userID ;
228230 // 2. MEXC-style method?
@@ -242,9 +244,10 @@ export function getServer(
242244 return callback (
243245 {
244246 code : grpc . status . INTERNAL ,
245- message : "Error: fetching account ID not supported for this broker" ,
247+ message :
248+ "Error: fetching account ID not supported for this broker" ,
246249 } ,
247- null
250+ null ,
248251 ) ;
249252 }
250253
@@ -253,7 +256,6 @@ export function getServer(
253256 proof : verityProof ,
254257 result : JSON . stringify ( { accountId, uid } ) ,
255258 } ) ;
256-
257259 } catch ( error ) {
258260 log . error ( `Error fetching account ID ${ cex } :` , error ) ;
259261 callback (
0 commit comments