Skip to content

Commit

Permalink
safeValue default values
Browse files Browse the repository at this point in the history
  • Loading branch information
samgermain committed May 28, 2022
1 parent 4a4b2bb commit 744d3d6
Show file tree
Hide file tree
Showing 38 changed files with 83 additions and 83 deletions.
6 changes: 3 additions & 3 deletions js/aax.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ module.exports = class aax extends Exchange {
// ]
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
const result = [];
for (let i = 0; i < data.length; i++) {
const market = data[i];
Expand Down Expand Up @@ -1209,7 +1209,7 @@ module.exports = class aax extends Exchange {
// "ts":1573530401020
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
const timestamp = this.safeInteger (response, 'ts');
const result = {
'info': response,
Expand Down Expand Up @@ -2483,7 +2483,7 @@ module.exports = class aax extends Exchange {
// ]
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
const rates = [];
for (let i = 0; i < data.length; i++) {
const entry = data[i];
Expand Down
2 changes: 1 addition & 1 deletion js/ascendex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ module.exports = class ascendex extends Exchange {
// ]
// }
//
const marginRequirements = this.safeValue (info, 'marginRequirements');
const marginRequirements = this.safeValue (info, 'marginRequirements', []);
const id = this.safeString (info, 'symbol');
market = this.safeMarket (id, market);
const tiers = [];
Expand Down
6 changes: 3 additions & 3 deletions js/bibox.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ module.exports = class bibox extends Exchange {
// "ver":"1.1"
// }
//
const markets = this.safeValue (response, 'result');
const markets = this.safeValue (response, 'result', []);
const request2 = {
'cmd': 'tradeLimit',
};
Expand Down Expand Up @@ -549,7 +549,7 @@ module.exports = class bibox extends Exchange {
// "cmd":"currencies"
// }
//
const currencies = this.safeValue (response, 'result');
const currencies = this.safeValue (response, 'result', []);
const result = {};
for (let i = 0; i < currencies.length; i++) {
const currency = currencies[i];
Expand Down Expand Up @@ -647,7 +647,7 @@ module.exports = class bibox extends Exchange {
//
const outerResults = this.safeValue (response, 'result');
const firstResult = this.safeValue (outerResults, 0, {});
const currencies = this.safeValue (firstResult, 'result');
const currencies = this.safeValue (firstResult, 'result', []);
const result = {};
for (let i = 0; i < currencies.length; i++) {
const currency = currencies[i];
Expand Down
10 changes: 5 additions & 5 deletions js/binance.js
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ module.exports = class binance extends Exchange {
result[code] = account;
}
} else if (type === 'savings') {
const positionAmountVos = this.safeValue (response, 'positionAmountVos');
const positionAmountVos = this.safeValue (response, 'positionAmountVos', []);
for (let i = 0; i < positionAmountVos.length; i++) {
const entry = positionAmountVos[i];
const currencyId = this.safeString (entry, 'asset');
Expand Down Expand Up @@ -4053,7 +4053,7 @@ module.exports = class binance extends Exchange {
const entry = response[i];
const currencyId = this.safeString (entry, 'coin');
const code = this.safeCurrencyCode (currencyId);
const networkList = this.safeValue (entry, 'networkList');
const networkList = this.safeValue (entry, 'networkList', []);
withdrawFees[code] = {};
for (let j = 0; j < networkList.length; j++) {
const networkEntry = networkList[j];
Expand Down Expand Up @@ -4485,7 +4485,7 @@ module.exports = class binance extends Exchange {

parseAccountPositions (account) {
const positions = this.safeValue (account, 'positions');
const assets = this.safeValue (account, 'assets');
const assets = this.safeValue (account, 'assets', []);
const balances = {};
for (let i = 0; i < assets.length; i++) {
const entry = assets[i];
Expand Down Expand Up @@ -4904,7 +4904,7 @@ module.exports = class binance extends Exchange {
const entry = response[i];
const marketId = this.safeString (entry, 'symbol');
const symbol = this.safeSymbol (marketId);
const brackets = this.safeValue (entry, 'brackets');
const brackets = this.safeValue (entry, 'brackets', []);
const result = [];
for (let j = 0; j < brackets.length; j++) {
const bracket = brackets[j];
Expand Down Expand Up @@ -4997,7 +4997,7 @@ module.exports = class binance extends Exchange {
const marketId = this.safeString (info, 'symbol');
const safeSymbol = this.safeSymbol (marketId);
market = this.safeMarket (safeSymbol, market);
const brackets = this.safeValue (info, 'brackets');
const brackets = this.safeValue (info, 'brackets', []);
const tiers = [];
for (let j = 0; j < brackets.length; j++) {
const bracket = brackets[j];
Expand Down
4 changes: 2 additions & 2 deletions js/bitso.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ module.exports = class bitso extends Exchange {
// },
// ]
// }
const markets = this.safeValue (response, 'payload');
const markets = this.safeValue (response, 'payload', []);
const result = [];
for (let i = 0; i < markets.length; i++) {
const market = markets[i];
Expand Down Expand Up @@ -300,7 +300,7 @@ module.exports = class bitso extends Exchange {

parseBalance (response) {
const payload = this.safeValue (response, 'payload', {});
const balances = this.safeValue (payload, 'balances');
const balances = this.safeValue (payload, 'balances', []);
const result = {
'info': response,
'timestamp': undefined,
Expand Down
6 changes: 3 additions & 3 deletions js/bkex.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ module.exports = class bkex extends Exchange {
// "status": 0
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
const result = [];
for (let i = 0; i < data.length; i++) {
const market = data[i];
Expand Down Expand Up @@ -336,7 +336,7 @@ module.exports = class bkex extends Exchange {
// "status": 0
// }
//
const data = this.safeValue (response, 'data', {});
const data = this.safeValue (response, 'data', []);
const result = {};
for (let i = 0; i < data.length; i++) {
const currency = data[i];
Expand Down Expand Up @@ -768,7 +768,7 @@ module.exports = class bkex extends Exchange {
// }
//
const balances = this.safeValue (response, 'data');
const wallets = this.safeValue (balances, 'WALLET');
const wallets = this.safeValue (balances, 'WALLET', []);
const result = { 'info': wallets };
for (let i = 0; i < wallets.length; i++) {
const wallet = wallets[i];
Expand Down
2 changes: 1 addition & 1 deletion js/bl3p.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = class bl3p extends Exchange {

parseBalance (response) {
const data = this.safeValue (response, 'data', {});
const wallets = this.safeValue (data, 'wallets');
const wallets = this.safeValue (data, 'wallets', {});
const result = { 'info': data };
const codes = Object.keys (this.currencies);
for (let i = 0; i < codes.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion js/btctradeua.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports = class btctradeua extends Exchange {

parseBalance (response) {
const result = { 'info': response };
const balances = this.safeValue (response, 'accounts');
const balances = this.safeValue (response, 'accounts', []);
for (let i = 0; i < balances.length; i++) {
const balance = balances[i];
const currencyId = this.safeString (balance, 'currency');
Expand Down
2 changes: 1 addition & 1 deletion js/btcturk.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ module.exports = class btcturk extends Exchange {
const quoteId = this.safeString (entry, 'denominator');
const base = this.safeCurrencyCode (baseId);
const quote = this.safeCurrencyCode (quoteId);
const filters = this.safeValue (entry, 'filters');
const filters = this.safeValue (entry, 'filters', []);
let minPrice = undefined;
let maxPrice = undefined;
let minAmount = undefined;
Expand Down
4 changes: 2 additions & 2 deletions js/buda.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ module.exports = class buda extends Exchange {
* @returns {[dict]} an array of objects representing market data
*/
const marketsResponse = await this.publicGetMarkets (params);
const markets = this.safeValue (marketsResponse, 'markets');
const markets = this.safeValue (marketsResponse, 'markets', []);
const currenciesResponse = await this.publicGetCurrencies ();
const currencies = this.safeValue (currenciesResponse, 'currencies');
const result = [];
Expand Down Expand Up @@ -615,7 +615,7 @@ module.exports = class buda extends Exchange {

parseBalance (response) {
const result = { 'info': response };
const balances = this.safeValue (response, 'balances');
const balances = this.safeValue (response, 'balances', []);
for (let i = 0; i < balances.length; i++) {
const balance = balances[i];
const currencyId = this.safeString (balance, 'id');
Expand Down
2 changes: 1 addition & 1 deletion js/bybit.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ module.exports = class bybit extends Exchange {
const currencyId = this.safeString (currency, 'coin');
const code = this.safeCurrencyCode (currencyId);
const name = this.safeString (currency, 'name');
const chains = this.safeValue (currency, 'chains');
const chains = this.safeValue (currency, 'chains', []);
const networks = {};
for (let j = 0; j < chains.length; j++) {
const chain = chains[j];
Expand Down
8 changes: 4 additions & 4 deletions js/cdax.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ module.exports = class cdax extends Exchange {
// ]
// }
//
const markets = this.safeValue (response, 'data');
const markets = this.safeValue (response, 'data', []);
const numMarkets = markets.length;
if (numMarkets < 1) {
throw new NetworkError (this.id + ' fetchMarkets() returned empty response: ' + this.json (markets));
Expand Down Expand Up @@ -638,7 +638,7 @@ module.exports = class cdax extends Exchange {
*/
await this.loadMarkets ();
const response = await this.marketGetTickers (params);
const tickers = this.safeValue (response, 'data');
const tickers = this.safeValue (response, 'data', []);
const timestamp = this.safeInteger (response, 'ts');
const result = {};
for (let i = 0; i < tickers.length; i++) {
Expand Down Expand Up @@ -829,7 +829,7 @@ module.exports = class cdax extends Exchange {
// ]
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
let result = [];
for (let i = 0; i < data.length; i++) {
const trades = this.safeValue (data[i], 'data', []);
Expand Down Expand Up @@ -961,7 +961,7 @@ module.exports = class cdax extends Exchange {
// ]
// }
//
const currencies = this.safeValue (response, 'data');
const currencies = this.safeValue (response, 'data', []);
const result = {};
for (let i = 0; i < currencies.length; i++) {
const currency = currencies[i];
Expand Down
2 changes: 1 addition & 1 deletion js/coinbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ module.exports = class coinbase extends Exchange {
'limit': 100,
};
const response = await this.privateGetAccounts (this.extend (request, params));
const balances = this.safeValue (response, 'data');
const balances = this.safeValue (response, 'data', []);
const accounts = this.safeValue (params, 'type', this.options['accounts']);
const result = { 'info': response };
for (let b = 0; b < balances.length; b++) {
Expand Down
4 changes: 2 additions & 2 deletions js/coinex.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ module.exports = class coinex extends Exchange {
//
const data = this.safeValue (response, 'data');
const timestamp = this.safeInteger (data, 'date');
const tickers = this.safeValue (data, 'ticker');
const tickers = this.safeValue (data, 'ticker', {});
const marketIds = Object.keys (tickers);
const result = {};
for (let i = 0; i < marketIds.length; i++) {
Expand Down Expand Up @@ -3343,7 +3343,7 @@ module.exports = class coinex extends Exchange {
// }
//
const data = this.safeValue (response, 'data');
const result = this.safeValue (data, 'records');
const result = this.safeValue (data, 'records', []);
const rates = [];
for (let i = 0; i < result.length; i++) {
const entry = result[i];
Expand Down
6 changes: 3 additions & 3 deletions js/coinfalcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ module.exports = class coinfalcon extends Exchange {
// ]
// }
//
const markets = this.safeValue (response, 'data');
const markets = this.safeValue (response, 'data', []);
const result = [];
for (let i = 0; i < markets.length; i++) {
const market = markets[i];
Expand Down Expand Up @@ -300,7 +300,7 @@ module.exports = class coinfalcon extends Exchange {
// ]
// }
//
const tickers = this.safeValue (response, 'data');
const tickers = this.safeValue (response, 'data', []);
const result = {};
for (let i = 0; i < tickers.length; i++) {
const ticker = this.parseTicker (tickers[i]);
Expand Down Expand Up @@ -499,7 +499,7 @@ module.exports = class coinfalcon extends Exchange {

parseBalance (response) {
const result = { 'info': response };
const balances = this.safeValue (response, 'data');
const balances = this.safeValue (response, 'data', []);
for (let i = 0; i < balances.length; i++) {
const balance = balances[i];
const currencyId = this.safeString (balance, 'currency_code');
Expand Down
6 changes: 3 additions & 3 deletions js/coinflex.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ module.exports = class coinflex extends Exchange {
// ],
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
const result = [];
for (let i = 0; i < data.length; i++) {
const market = data[i];
Expand Down Expand Up @@ -500,7 +500,7 @@ module.exports = class coinflex extends Exchange {
// ]
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
const result = {};
for (let i = 0; i < data.length; i++) {
const entry = data[i];
Expand Down Expand Up @@ -1303,7 +1303,7 @@ module.exports = class coinflex extends Exchange {
}

parseBalance (data) {
const balances = this.safeValue (data, 'balances');
const balances = this.safeValue (data, 'balances', []);
const result = {};
for (let i = 0; i < balances.length; i++) {
const balance = balances[i];
Expand Down
4 changes: 2 additions & 2 deletions js/coinmate.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module.exports = class coinmate extends Exchange {
// ]
// }
//
const data = this.safeValue (response, 'data');
const data = this.safeValue (response, 'data', []);
const result = [];
for (let i = 0; i < data.length; i++) {
const market = data[i];
Expand Down Expand Up @@ -285,7 +285,7 @@ module.exports = class coinmate extends Exchange {
}

parseBalance (response) {
const balances = this.safeValue (response, 'data');
const balances = this.safeValue (response, 'data', {});
const result = { 'info': response };
const currencyIds = Object.keys (balances);
for (let i = 0; i < currencyIds.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion js/currencycom.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ module.exports = class currencycom extends Exchange {
if (this.options['adjustForTimeDifference']) {
await this.loadTimeDifference ();
}
const markets = this.safeValue (response, 'symbols');
const markets = this.safeValue (response, 'symbols', []);
const result = [];
for (let i = 0; i < markets.length; i++) {
const market = markets[i];
Expand Down
2 changes: 1 addition & 1 deletion js/ftx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ module.exports = class ftx extends Exchange {
// ]
// }
//
const result = this.safeValue (response, 'result');
const result = this.safeValue (response, 'result', []);
const rates = [];
for (let i = 0; i < result.length; i++) {
const entry = result[i];
Expand Down
Loading

0 comments on commit 744d3d6

Please sign in to comment.