Modify /bisq/api/v1/markets/markets to only return active markets

As per https://github.com/bisq-network/bisq/issues/4826 and https://github.com/bisq-network/bisq/pull/4831
This commit is contained in:
wiz
2020-11-23 22:46:14 +09:00
parent 824bc21035
commit d613aec395
2 changed files with 17 additions and 5 deletions

View File

@@ -6,6 +6,8 @@ import * as datetime from 'locutus/php/datetime';
class BisqMarketsApi {
private cryptoCurrencyData: Currency[] = [];
private fiatCurrencyData: Currency[] = [];
private activeCryptoCurrencyData: Currency[] = [];
private activeFiatCurrencyData: Currency[] = [];
private offersData: OffersData[] = [];
private tradesData: TradesData[] = [];
private fiatCurrenciesIndexed: { [code: string]: true } = {};
@@ -32,9 +34,11 @@ class BisqMarketsApi {
});
}
setCurrencyData(cryptoCurrency: Currency[], fiatCurrency: Currency[]) {
setCurrencyData(cryptoCurrency: Currency[], fiatCurrency: Currency[], activeCryptoCurrency: Currency[], activeFiatCurrency: Currency[]) {
this.cryptoCurrencyData = cryptoCurrency,
this.fiatCurrencyData = fiatCurrency;
this.fiatCurrencyData = fiatCurrency,
this.activeCryptoCurrencyData = activeCryptoCurrency,
this.activeFiatCurrencyData = activeFiatCurrency;
this.fiatCurrenciesIndexed = {};
this.allCurrenciesIndexed = {};
@@ -56,7 +60,7 @@ class BisqMarketsApi {
}
getCurrencies(
type: 'crypto' | 'fiat' | 'all' = 'all',
type: 'crypto' | 'fiat' | 'active' | 'all' = 'all',
): Currencies {
let currencies: Currency[];
@@ -67,6 +71,9 @@ class BisqMarketsApi {
case 'crypto':
currencies = this.cryptoCurrencyData;
break;
case 'active':
currencies = this.activeCryptoCurrencyData.concat(this.activeFiatCurrencyData);
break;
case 'all':
default:
currencies = this.cryptoCurrencyData.concat(this.fiatCurrencyData);
@@ -136,9 +143,10 @@ class BisqMarketsApi {
getMarkets(): Markets {
const allCurrencies = this.getCurrencies();
const activeCurrencies = this.getCurrencies('active');
const markets = {};
for (const currency of Object.keys(allCurrencies)) {
for (const currency of Object.keys(activeCurrencies)) {
if (allCurrencies[currency].code === 'BTC') {
continue;
}