Repository: ccxt/ccxt
Pull request: parseDepositAddresses undefined result fix [ci deploy]
fixes: #17209
fixes: #17216

**TypeScript**

```
% huobi fetchDepositAddress USDT              
2023-03-16T19:24:14.209Z
Node.js: v18.9.0
CCXT v3.0.15
huobi.fetchDepositAddress (USDT)
2023-03-16T19:24:19.882Z iteration 0 passed in 397 ms

{
  currency: 'USDT',
  address: 'TFqAnCgT6aHJNUUWGMMpdj5jAnqCgHPeNr',
  tag: undefined,
  network: 'TRC20',
  note: undefined,
  info: {
    userId: '35930539',
    currency: 'usdt',
    address: 'TFqAnCgT6aHJNUUWGMMpdj5jAnqCgHPeNr',
    addressTag: '',
    chain: 'trc20usdt'
  }
}
2023-03-16T19:24:19.882Z iteration 1 passed in 397 ms
```
```
% okx fetchDepositAddress USDT              
2023-03-16T19:25:15.200Z
Node.js: v18.9.0
CCXT v3.0.15
okx.fetchDepositAddress (USDT)
2023-03-16T19:25:19.551Z iteration 0 passed in 499 ms

{
  currency: 'USDT',
  address: '0x52c79b86e8d5a583614f7e72cc171e909d807259',
  tag: undefined,
  network: 'ERC20',
  info: {
    chain: 'USDT-ERC20',
    ctAddr: '831ec7',
    ccy: 'USDT',
    to: '6',
    addr: '0x52c79b86e8d5a583614f7e72cc171e909d807259',
    selected: true
  }
}
2023-03-16T19:25:19.551Z iteration 1 passed in 499 ms
```

--------------

Will add python, php, js tests right away

Problem statement:
[huobi, okx] Can't fetch deposit address
### Operating System

linux, windows

### Programming Languages

JS

### CCXT Version

3.0.11

### Description

Dear fellows,
since around 2.9.16 a few exchanges can't get deposit addresses.

Please take a look, thanks!


### Code

```Javascript
this.exchange = new ccxt[this.exchangeName](this.params);
let depositAddr = await this.exchange.fetchDepositAddress("ETH");  
```
```
TypeError: Cannot read properties of undefined (reading 'push')
    at huobi.parseDepositAddresses (REDACTED\node_modules\ccxt\dist\ccxt.bundle.cjs:20889:20)
    at huobi.fetchDepositAddressesByNetwork (REDACTED\node_modules\ccxt\dist\ccxt.bundle.cjs:141231:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async huobi.fetchDepositAddress (REDACTED\node_modules\ccxt\dist\ccxt.bundle.cjs:141246:34)
```

Cannot parse_deposit_addresses
### Operating System

ubuntu

### Programming Languages

python

### CCXT Version

3.0.13

### Description

While attempting to call `fetch_deposit_address_by_network` on the async implementation for `okx` I encountered the following:

`AttributeError: 'NoneType' object has no attribute 'append'`

On looking at the source, code, I am seeing the following culprit:

```python
 def parse_deposit_addresses(self, addresses, codes=None, indexed=True, params={}):
        result = None
        for i in range(0, len(addresses)):
            address = self.extend(self.parse_deposit_address(addresses[i]), params)
```

A bug in the above block attempts to extend result which has type `None` (it should be a list).



### Code

```
  

```

Hints from issue discussion:

Commit message: parseDepositAddresses undefined result fix

Patch to review:
diff --git a/ts/src/base/Exchange.ts b/ts/src/base/Exchange.ts
index 0e997acc83e15..638d3d4d4982a 100644
--- a/ts/src/base/Exchange.ts
+++ b/ts/src/base/Exchange.ts
@@ -3566,16 +3566,15 @@ export default class Exchange {
     }
 
     parseDepositAddresses (addresses, codes = undefined, indexed = true, params = {}) {
-        let result = undefined;
+        let result: any[] | {} = [];
         for (let i = 0; i < addresses.length; i++) {
             const address = this.extend ((this as any).parseDepositAddress (addresses[i]), params);
-            result.push (address);
+            (result as any[]).push (address);
         }
         if (codes !== undefined) {
             result = this.filterByArray (result, 'currency', codes, false);
         }
-        result = indexed ? this.indexBy (result, 'currency') : result;
-        return result;
+        return indexed ? this.indexBy (result, 'currency') : result;
     }
 
     parseBorrowInterests (response, market = undefined) {
diff --git a/ts/src/huobi.ts b/ts/src/huobi.ts
index 12c5b6bc10365..96e2af83ae1ec 100644
--- a/ts/src/huobi.ts
+++ b/ts/src/huobi.ts
@@ -4786,7 +4786,7 @@ export default class huobi extends Exchange {
         //     }
         //
         const data = this.safeValue (response, 'data', []);
-        const allAddresses = this.parseDepositAddresses (data, [ currency['code'] ], false);
+        const allAddresses = this.parseDepositAddresses (data, [ currency['code'] ], false) as any[];
         const addresses = [];
         for (let i = 0; i < allAddresses.length; i++) {
             const address = allAddresses[i];


Code review comments:
diff_hunk: @@ -3566,16 +3566,15 @@ export default class Exchange {
     }
 
     parseDepositAddresses (addresses, codes = undefined, indexed = true, params = {}) {
-        let result = undefined;
+        let result: any[] | {} = [];
path: ts/src/base/Exchange.ts
text: @user1:
@author this annotation cannot be transpiled, we can probably get way with `any` here, I will take a look