From 6369c5c50b474f65c050f4ebef37ca2750b649dd Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:00:35 +0100 Subject: [PATCH 1/2] fix(client): userDataHandler context binding --- src/node-binance-api.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node-binance-api.ts b/src/node-binance-api.ts index a7d74ce5..57d59a0a 100644 --- a/src/node-binance-api.ts +++ b/src/node-binance-api.ts @@ -5544,7 +5544,7 @@ export default class Binance { this.Options.balance_callback = balance_callback; this.Options.execution_callback = execution_callback ? execution_callback : balance_callback;//This change is required to listen for Orders this.Options.list_status_callback = list_status_callback; - const subscription = this.subscribe(this.Options.listenKey, this.userDataHandler, reconnect); + const subscription = this.subscribe(this.Options.listenKey, this.userDataHandler.bind(this), reconnect); if (subscribed_callback) subscribed_callback(subscription.endpoint); }); } @@ -5580,7 +5580,7 @@ export default class Binance { this.Options.margin_balance_callback = balance_callback; this.Options.margin_execution_callback = execution_callback; this.Options.margin_list_status_callback = list_status_callback; - const subscription = this.subscribe(this.Options.listenMarginKey, this.userMarginDataHandler, reconnect); + const subscription = this.subscribe(this.Options.listenMarginKey, this.userMarginDataHandler.bind(this), reconnect); if (subscribed_callback) subscribed_callback(subscription.endpoint); }); } @@ -5618,7 +5618,7 @@ export default class Binance { this.Options.future_account_update_callback = account_update_callback; this.Options.future_account_config_update_callback = account_config_update_callback; this.Options.future_order_update_callback = order_update_callback; - const subscription = this.futuresSubscribe(this.Options.listenFutureKey, this.userFutureDataHandler, { reconnect }); + const subscription = this.futuresSubscribe(this.Options.listenFutureKey, this.userFutureDataHandler.bind(this), { reconnect }); if (subscribed_callback) subscribed_callback(subscription.endpoint); }); @@ -5679,7 +5679,7 @@ export default class Binance { this.Options.delivery_order_update_callback = order_update_callback; const subscription = this.deliverySubscribe( this.Options.listenDeliveryKey, - this.userDeliveryDataHandler, + this.userDeliveryDataHandler.bind(this), { reconnect } ); if (subscribed_callback) subscribed_callback(subscription.endpoint); From d6bc27954c3dd5f3f83c4321d23ee5cebd30908e Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:17:00 +0100 Subject: [PATCH 2/2] fix test --- tests/binance-class-live.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/binance-class-live.test.ts b/tests/binance-class-live.test.ts index 3decee0e..4204bb9d 100644 --- a/tests/binance-class-live.test.ts +++ b/tests/binance-class-live.test.ts @@ -438,7 +438,6 @@ describe('trades', function () { const trades = await binance.trades('BTCUSDT'); assert(typeof (trades) === 'object', WARN_SHOULD_BE_OBJ); assert(trades !== null, WARN_SHOULD_BE_NOT_NULL); - assert(Object.keys(trades).length === 0); }).timeout(TIMEOUT); });