Repository: ccxt/ccxt
Pull request: fix(binance) - editOrder for spot
currently this does not work:
```
const o1 = await e.createOrder('ADA/USDT', 'limit', 'buy', 50, 0.2);
const o2 = await e.editOrder(o1.id, 'ADA/USDT', 'limit', 'buy', 50, 0.21);
```
PR seems to fix it, but @pcriadoperez I see that you were working on WS orders & related things in last month, so you could know this better - can you confirm whether this PR would fix it correctly?

(fixes #18667)

Problem statement:
[binance] editOrder recieved error "Mandatory parameter 'type' was not sent"
### Operating System

MacOS

### Programming Languages

JavaScript

### CCXT Version

4.0.38

### Description

when call editOrder with params (id, symbol, type, side, amount, price), I got the response error blow this.

```
BadRequest: binance {"code":-1102,"msg":"Mandatory parameter 'type' was not sent, was empty/null, or malformed."}
```

the verbose detail:

```
 {"symbol":"USDCUSDT","origClientOrderId":"xxx","orderId":xxx,"orderListId":-1,"clientOrderId":"xxx","transactTime":1690380923704,"price":"1.00010000","origQty":"499.00000000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"}
```

Hints from issue discussion:
I've reproduced the issue and working on it atm

Commit message: fix(binance) - editOrder for spot

Patch to review:
diff --git a/ts/src/binance.ts b/ts/src/binance.ts
index ee5c5e49e60cd..0a7635f130cae 100644
--- a/ts/src/binance.ts
+++ b/ts/src/binance.ts
@@ -3677,15 +3677,16 @@ export default class binance extends Exchange {
         if (!market['spot']) {
             throw new NotSupported (this.id + ' editSpotOrder() does not support ' + market['type'] + ' orders');
         }
-        const request = {
-            'symbol': market['id'],
-            'side': side.toUpperCase (),
-        };
         const clientOrderId = this.safeStringN (params, [ 'newClientOrderId', 'clientOrderId', 'origClientOrderId' ]);
         let response = undefined;
         if (market['spot']) {
-            response = await this.privatePostOrderCancelReplace (this.extend (request, params));
+            const payload = this.editSpotOrderRequest (id, symbol, type, side, amount, price, params);
+            response = await this.privatePostOrderCancelReplace (payload);
         } else {
+            const request = {
+                'symbol': market['id'],
+                'side': side.toUpperCase (),
+            };
             request['orderId'] = id;
             request['quantity'] = this.amountToPrecision (symbol, amount);
             if (price !== undefined) {


Code review comments:
diff_hunk: @@ -3677,15 +3677,16 @@ export default class binance extends Exchange {
         if (!market['spot']) {
             throw new NotSupported (this.id + ' editSpotOrder() does not support ' + market['type'] + ' orders');
         }
-        const request = {
-            'symbol': market['id'],
-            'side': side.toUpperCase (),
-        };
         const clientOrderId = this.safeStringN (params, [ 'newClientOrderId', 'clientOrderId', 'origClientOrderId' ]);
         let response = undefined;
         if (market['spot']) {
-            response = await this.privatePostOrderCancelReplace (this.extend (request, params));
+            const payload = this.editSpotOrderRequest (id, symbol, type, side, amount, price, params);
+            response = await this.privatePostOrderCancelReplace (payload);
         } else {
+            const request = {
path: ts/src/binance.ts
text: @user1:
@author something is wrong here, we're inside `editSpotOrder` but we have an else branch that handles swap orders? 

@author:
yeah, i haven't looked around, i was looking just spot order request corrections... something was off yeh. 
also, maybe we neither need `if (!market['spot'])` check inside `editSpotOrder`.

@user1:
@author yeah I removed all of that

@author:
it might need later to be checked inside `editSwapOrder` or alike, i've not looked in other areas yet.